Ignore:
Timestamp:
12 Nov 2011, 07:19:51 (13 years ago)
Author:
uli
Message:

In tests we tell what we expect in detail from the new (not yet
existing methods).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/tests/test_imagestorage.py

    r7072 r7091  
    299299        self.assertTrue(
    300300            isinstance(result, DefaultStorage))
     301
     302    def test_delete_file(self):
     303        # we can remove stored files from storage
     304        fs = ExtFileStore()
     305        # First, we store a file in file store
     306        fs.createFile('sample.txt', StringIO('sample text'))
     307        # Then we delete it
     308        fs.deleteFile('sample.txt')
     309        # 'Deletion' means, next call to getFile should get None
     310        result = fs.getFile('sample.txt')
     311        self.assertTrue(result is None)
     312        # Hm, okay we can also check, whether it was really deleted
     313        self.assertTrue('sample.txt' not in os.listdir(fs.root))
     314        return
     315
     316    def test_delete_file_by_context_w_attr(self):
     317        # if we register a file name chooser, we can also delete a file
     318        # by context and attribute
     319        fs = ExtFileStore()
     320        context = CustomContext()
     321        file_id1 = IFileStoreNameChooser(context).chooseName()
     322        file_id2 = IFileStoreNameChooser(context).chooseName(attr='img')
     323        file_id3 = IFileStoreNameChooser(context).chooseName(attr='doc')
     324        fs = ExtFileStore()
     325        # create three files for a single context, each which
     326        # different content
     327        fs.createFile(file_id1, StringIO('my sample 1'))
     328        fs.createFile(file_id2, StringIO('my sample 2'))
     329        fs.createFile(file_id3, StringIO('my sample 3'))
     330        # now delete first two of these files
     331        fs.deleteFileByContext(context)
     332        fs.deleteFileByContext(context, attr='img')
     333        # Following getFile calls should give None for two of the
     334        # files.
     335        result1 = fs.getFileByContext(context)
     336        result2 = fs.getFileByContext(context, attr='img')
     337        result3 = fs.getFileByContext(context, attr='doc')
     338        self.assertEqual(result1.read(), 'my sample 1')
     339        self.assertEqual(result2, None)
     340        self.assertEqual(result3, None)
     341        return
Note: See TracChangeset for help on using the changeset viewer.