[Zope3-checkins] CVS: Zope3/src/zope/app/content/tests -
testi18nfile.py:1.5 testi18nimage.py:1.5
Stephan Richter
srichter at cosmos.phy.tufts.edu
Fri Feb 13 22:27:45 EST 2004
Update of /cvs-repository/Zope3/src/zope/app/content/tests
In directory cvs.zope.org:/tmp/cvs-serv31706/src/zope/app/content/tests
Modified Files:
testi18nfile.py testi18nimage.py
Log Message:
- Cleaned up some module doc strings.
- Put I18n content component interfaces together.
- Updated I18n Content Component implementation and tests.
=== Zope3/src/zope/app/content/tests/testi18nfile.py 1.4 => 1.5 ===
--- Zope3/src/zope/app/content/tests/testi18nfile.py:1.4 Thu Mar 13 13:49:06 2003
+++ Zope3/src/zope/app/content/tests/testi18nfile.py Fri Feb 13 22:27:14 2004
@@ -11,11 +11,10 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""
+"""Test I18nFile Content Component
$Id$
"""
-
import unittest
from zope.interface.verify import verifyClass
from zope.app.content.file import FileChunk
@@ -27,13 +26,10 @@
return list
-class Test(TestII18nAware):
-
+class I18nFileTest(TestII18nAware):
def _makeFile(self, *args, **kw):
- """ """
from zope.app.content.i18nfile import I18nFile
-
return I18nFile(*args, **kw)
@@ -45,16 +41,13 @@
def testEmpty(self):
-
file = self._makeFile()
-
self.assertEqual(file.getContentType(), '')
self.assertEqual(file.getData(), '')
self.assertEqual(file.getDefaultLanguage(), 'en')
def testConstructor(self):
-
file = self._makeFile('Foobar')
self.assertEqual(file.getContentType(), '')
self.assertEqual(file.getData(), 'Foobar')
@@ -63,7 +56,6 @@
self.assertEqual(file.getDefaultLanguage(), 'en')
self.assertEqual(sorted(file.getAvailableLanguages()), ['en'])
-
file = self._makeFile('Foobar', 'text/plain')
self.assertEqual(file.getContentType(), 'text/plain')
self.assertEqual(file.getData(), 'Foobar')
@@ -72,7 +64,6 @@
self.assertEqual(file.getDefaultLanguage(), 'en')
self.assertEqual(sorted(file.getAvailableLanguages()), ['en'])
-
file = self._makeFile(data='Foobar', contentType='text/plain')
self.assertEqual(file.getContentType(), 'text/plain')
self.assertEqual(file.getData(), 'Foobar')
@@ -81,7 +72,6 @@
self.assertEqual(file.getDefaultLanguage(), 'en')
self.assertEqual(sorted(file.getAvailableLanguages()), ['en'])
-
file = self._makeFile(data='Foobar', contentType='text/plain',
defaultLanguage='fr')
self.assertEqual(file.getContentType(), 'text/plain')
@@ -93,9 +83,7 @@
def testMutators(self):
-
file = self._makeFile()
-
file.setContentType('text/plain')
self.assertEqual(file.getContentType(), 'text/plain')
self.assertEqual(sorted(file.getAvailableLanguages()), ['en'])
@@ -123,7 +111,8 @@
self.assertEqual(file.getSize(), len('Blah'))
self.assertEqual(file.getSize('fr'), len('Barbaz'))
self.assertEqual(file.getSize('lt'), len('Quux'))
- self.assertEqual(sorted(file.getAvailableLanguages()), ['en', 'fr', 'lt'])
+ self.assertEqual(sorted(file.getAvailableLanguages()),
+ ['en', 'fr', 'lt'])
file.removeLanguage('lt')
self.assertEqual(file.getContentType(), 'text/html')
@@ -145,13 +134,13 @@
self.assertEqual(file.getData('lt'), 'Blah')
self.assertEqual(file.getSize('lt'), len('Blah'))
- self.assertRaises(ValueError, file.removeLanguage, file.getDefaultLanguage())
+ self.assertRaises(ValueError,
+ file.removeLanguage, file.getDefaultLanguage())
self.assertRaises(ValueError, file.setDefaultLanguage, 'nonexistent')
def testLargeDataInput(self):
-
file = self._makeFile()
# Insert as string
@@ -176,9 +165,8 @@
def testInterface(self):
-
from zope.app.interfaces.content.file import IFile
- from zope.app.interfaces.content.i18nfile import II18nFile
+ from zope.app.interfaces.content.i18n import II18nFile
from zope.app.content.i18nfile import I18nFile
from zope.i18n.interfaces import II18nAware
@@ -193,10 +181,8 @@
def testSetDefaultLanguage(self):
-
# getDefaultLanguage and getAvailableLanguages are tested in the
# above tests
-
file = self._makeFile()
file.setData('', language='lt')
@@ -205,8 +191,9 @@
def test_suite():
- loader = unittest.TestLoader()
- return loader.loadTestsFromTestCase(Test)
+ return unittest.TestSuite((
+ unittest.makeSuite(I18nFileTest),
+ ))
-if __name__=='__main__':
- unittest.TextTestRunner().run(test_suite())
+if __name__ == '__main__':
+ unittest.main(defaultTest='test_suite')
=== Zope3/src/zope/app/content/tests/testi18nimage.py 1.4 => 1.5 ===
--- Zope3/src/zope/app/content/tests/testi18nimage.py:1.4 Thu Mar 13 13:49:06 2003
+++ Zope3/src/zope/app/content/tests/testi18nimage.py Fri Feb 13 22:27:14 2004
@@ -11,11 +11,10 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""
+"""Test I18nImage Content Component
$Id$
"""
-
import unittest
from zope.interface.verify import verifyClass
from zope.i18n.tests.testii18naware import TestII18nAware
@@ -26,13 +25,10 @@
return list
-class Test(TestII18nAware):
-
+class I18nImageTest(TestII18nAware):
def _makeImage(self, *args, **kw):
- """ """
from zope.app.content.i18nimage import I18nImage
-
return I18nImage(*args, **kw)
@@ -44,16 +40,13 @@
def testEmpty(self):
-
file = self._makeImage()
-
self.assertEqual(file.getContentType(), '')
self.assertEqual(file.getData(), '')
self.assertEqual(file.getDefaultLanguage(), 'en')
def testConstructor(self):
-
file = self._makeImage('Data')
self.assertEqual(file.getContentType(), '')
self.assertEqual(file.getData(), 'Data')
@@ -72,7 +65,6 @@
def testMutators(self):
-
# XXX What's the point of this test? Does it test that data
# contents override content-type? Or not? If the former, then
# real image data should be used.
@@ -147,10 +139,9 @@
def testInterface(self):
-
from zope.app.content.image import IImage
from zope.app.content.i18nimage import I18nImage
- from zope.app.interfaces.content.i18nfile import II18nFile
+ from zope.app.interfaces.content.i18n import II18nFile, II18nImage
from zope.i18n.interfaces import II18nAware
self.failUnless(IImage.isImplementedByInstancesOf(I18nImage))
@@ -162,22 +153,23 @@
self.failUnless(II18nFile.isImplementedByInstancesOf(I18nImage))
self.failUnless(verifyClass(II18nFile, I18nImage))
+ self.failUnless(II18nImage.isImplementedByInstancesOf(I18nImage))
+ self.failUnless(verifyClass(II18nImage, I18nImage))
- def testSetDefaultLanguage(self):
+ def testSetDefaultLanguage(self):
# getDefaultLanguage and getAvailableLanguages are tested in the
# above tests
-
file = self._makeImage()
-
file.setData('', language='lt')
file.setDefaultLanguage('lt')
self.assertEqual(file.getDefaultLanguage(), 'lt')
def test_suite():
- loader = unittest.TestLoader()
- return loader.loadTestsFromTestCase(Test)
+ return unittest.TestSuite((
+ unittest.makeSuite(I18nImageTest),
+ ))
-if __name__=='__main__':
- unittest.TextTestRunner().run(test_suite())
+if __name__ == '__main__':
+ unittest.main(defaultTest='test_suite')
More information about the Zope3-Checkins
mailing list