예제 #1
0
 def test_ImageContentTypeUponConstruction(self):
     # Test the content type after calling the constructor with the
     # file object being passed in (http://www.zope.org/Collectors/CMF/370)
     testfile = open(TEST_JPG, 'rb')
     image = Image('testimage', file=testfile)
     testfile.close()
     self.assertEqual(image.Format(), 'image/jpeg')
     self.assertEqual(image.content_type, 'image/jpeg')
예제 #2
0
파일: test_Image.py 프로젝트: goschtl/zope
 def test_Image_setFormat(self):
     # Setting the DC.format must also set the content_type property
     image = Image('testimage', format='image/jpeg')
     self.assertEqual(image.Format(), 'image/jpeg')
     self.assertEqual(image.content_type, 'image/jpeg')
     image.setFormat('image/gif')
     self.assertEqual(image.Format(), 'image/gif')
     self.assertEqual(image.content_type, 'image/gif')
예제 #3
0
 def test_getId_on_old_Image_instance(self):
     image = self.site._setObject('testimage', Image('testimage'))
     self.assertEqual(image.getId(), 'testimage')
     self.assertEqual(image.id, 'testimage')
     # Mimick old instance when base classes had OFS.Image.Image first
     image.__name__ = 'testimage'
     delattr(image, 'id')
     self.assertEqual(image.getId(), 'testimage')
     self.assertEqual(image.id(), 'testimage')
예제 #4
0
 def test_Image_setFormat(self):
     # Setting the format must also set the content_type property
     image = Image('testimage', format='image/jpeg')
     self.assertEqual(image.Format(), 'image/jpeg')
     self.assertEqual(image.content_type, 'image/jpeg')
     image.setFormat('image/gif')
     self.assertEqual(image.Format(), 'image/gif')
     self.assertEqual(image.content_type, 'image/gif')
예제 #5
0
    def test_EditWithEmptyFile(self):
        # Test handling of empty file uploads
        image = Image('testimage')

        testfile = open(TEST_JPG, 'rb')
        image.edit(file=testfile)
        testfile.seek(0, 2)
        testfilesize = testfile.tell()
        testfile.close()

        assert image.get_size() == testfilesize

        emptyfile = cStringIO.StringIO()
        image.edit(file=emptyfile)

        assert image.get_size() > 0
        assert image.get_size() == testfilesize
예제 #6
0
파일: test_Image.py 프로젝트: goschtl/zope
    def test_EditWithEmptyFile(self):
        """ Test handling of empty file uploads """
        image = Image('testimage')

        testfile = open(TEST_JPG, 'rb')
        image.edit(file=testfile)
        testfile.seek(0,2)
        testfilesize = testfile.tell()
        testfile.close()

        assert image.get_size() == testfilesize

        emptyfile = cStringIO.StringIO()
        image.edit(file=emptyfile)

        assert image.get_size() > 0
        assert image.get_size() == testfilesize