[CMF-checkins] CVS: CMF - TestImage.jpg:1.1 test_Image.py:1.1 test_all.py:1.2
Jeffrey Shell
jeffrey@digicool.com
Mon, 21 May 2001 09:48:14 -0400 (EDT)
Update of /cvs-repository/CMF/CMFDefault/tests
In directory korak.digicool.com:/home/jeffrey/InstanceHomes/cmf-dev/CMF/CMFDefault/tests
Modified Files:
test_all.py
Added Files:
TestImage.jpg test_Image.py
Log Message:
Added new test_Image module as basis for building tests for Image Elements. Currently, it only tests handling of receiving empty files
--- Added File TestImage.jpg in package CMF ---
ÿØÿà
ÿÀ
ÿÀ
„”EF¤´VÓU(òãóÄÔäôeu…•¥µÅÕåõfv†–¦¶ÆÖæö7GWgw‡—§·Ç×ç÷8HXhxˆ˜¨¸ÈØèø)9IYiy‰™©¹ÉÙéù*:JZjzŠšªºÊÚêú
&6E'dtU7ò£³Ã()Óã󄔤´ÄÔäôeu…•¥µÅÕåõFVfv†–¦¶ÆÖæöGWgw‡—§·Ç×ç÷8HXhxˆ˜¨¸ÈØèø9IYiy‰™©¹ÉÙéù*:JZjzŠšªºÊÚêúÿÚ
--- Added File test_Image.py in package CMF ---
import unittest, os, cStringIO
from Products.CMFDefault.Image import Image
TESTS_HOME = os.path.join(INSTANCE_HOME, 'Products/CMFDefault/tests')
TEST_JPG = os.path.join(TESTS_HOME, 'TestImage.jpg')
class TestImageElement(unittest.TestCase):
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
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestImageElement))
return suite
def run():
suite = test_suite()
return unittest.TextTestRunner().run(suite)
if __name__ == '__main__':
import sys
result = run()
if result.wasSuccessful():
sys.exit(0)
else:
sys.exit(1)
--- Updated File test_all.py in package CMF --
--- test_all.py 2001/05/19 19:01:43 1.1
+++ test_all.py 2001/05/21 13:48:13 1.2
@@ -1,5 +1,6 @@
import unittest
from Products.CMFDefault.tests import test_Document
+from Products.CMFDefault.tests import test_Image
from Products.CMFDefault.tests import test_MetadataTool
from Products.CMFDefault.tests import test_utils
@@ -10,6 +11,7 @@
"""
suite = unittest.TestSuite((
test_Document.test_suite(),
+ test_Image.test_suite(),
test_MetadataTool.test_suite(),
test_utils.test_suite(),
))