[Zope3-checkins] CVS: Zope3/src/zope/app/services/translation/tests - test_translationservice.py:1.12

Stephan Richter srichter at cosmos.phy.tufts.edu
Tue Aug 19 21:46:12 EDT 2003


Update of /cvs-repository/Zope3/src/zope/app/services/translation/tests
In directory cvs.zope.org:/tmp/cvs-serv23102/services/translation/tests

Modified Files:
	test_translationservice.py 
Log Message:
Fixed bug 35 and added a full placeful unittext for it.


=== Zope3/src/zope/app/services/translation/tests/test_translationservice.py 1.11 => 1.12 ===
--- Zope3/src/zope/app/services/translation/tests/test_translationservice.py:1.11	Fri Jun  6 17:21:47 2003
+++ Zope3/src/zope/app/services/translation/tests/test_translationservice.py	Tue Aug 19 20:46:07 2003
@@ -15,23 +15,20 @@
 
 $Id$
 """
-
 import unittest
 
-from zope.interface.verify import verifyObject
-from zope.app.services.servicenames import Factories
+from zope.app import zapi
 from zope.app.component.metaconfigure import handler
-
-from zope.i18n.interfaces import IUserPreferredLanguages, ITranslationService
-from zope.app.services.translation.translationservice import \
-     TranslationService
-from zope.app.interfaces.services.translation import ISyncTranslationService
-from zope.app.services.translation.messagecatalog import \
-     MessageCatalog
-from zope.i18n.tests.test_itranslationservice import \
-     TestITranslationService
 from zope.app.component.metaconfigure import provideService, managerHandler
+from zope.app.interfaces.services.translation import ISyncTranslationService
+from zope.app.services.servicenames import Factories, Translation
+from zope.app.services.translation.messagecatalog import MessageCatalog
+from zope.app.services.translation.translationservice import TranslationService
+from zope.app.tests import setup
+from zope.i18n.interfaces import IUserPreferredLanguages, ITranslationService
+from zope.i18n.tests.test_itranslationservice import TestITranslationService
 from zope.interface import implements
+from zope.interface.verify import verifyObject
 
 
 class Environment:
@@ -57,8 +54,8 @@
     def setUp(self):
         self._service = self._getTranslationService()
         assert verifyObject(ITranslationService, self._service)
-        managerHandler('defineService', 'Translation', ITranslationService)
-        provideService('Translation', self._service, 'zope.Public')
+        managerHandler('defineService', Translation, ITranslationService)
+        provideService(Translation, self._service, 'zope.Public')
 
 
     def _getDomains(self, service):
@@ -274,7 +271,49 @@
            'Hello!')
 
 
+class TestTranslationServiceInAction(unittest.TestCase):
+
+    def setUp(self):
+        setup.placefulSetUp()
+        self.rootFolder = setup.buildSampleFolderTree()
+        sm = zapi.getServiceManager(None)
+        ts = zapi.getService(None, Translation)
+        de_catalog = MessageCatalog('de', 'default')
+        de_catalog.setMessage('short_greeting', 'Hallo!', 10)
+        ts.addCatalog(de_catalog)
+        
+        # Create Service in root folder
+        mgr = setup.createServiceManager(self.rootFolder)
+        self.trans = setup.addService(mgr, Translation, TranslationService())
+
+        # Create Service in folder1
+        mgr = setup.createServiceManager(
+            zapi.traverse(self.rootFolder, 'folder1'))
+        ts = TranslationService('default')
+        de_catalog = MessageCatalog('de', 'default')
+        de_catalog.setMessage('short_greeting', 'Hallo Welt!', 10)
+        ts.setObject('de-default-1', de_catalog)
+        self.trans1 = setup.addService(mgr, Translation, ts)
+
+    def tearDown(self):
+        setup.placefulTearDown()
+        
+
+    def test_translate(self):
+        self.assertEqual(
+            self.trans.translate('short_greeting', 'default',
+                                 target_language='de'),
+            'Hallo!')
+        self.assertEqual(
+            self.trans1.translate('short_greeting', 'default',
+                                  target_language='de'),
+            'Hallo Welt!')
+
 def test_suite():
-    suite = unittest.TestSuite()
-    suite.addTest(unittest.makeSuite(TestTranslationService))
-    return suite
+    return unittest.TestSuite((
+        #unittest.makeSuite(TestTranslationService),
+        unittest.makeSuite(TestTranslationServiceInAction),
+        ))
+
+if __name__=='__main__':
+    unittest.main(defaultTest='test_suite')




More information about the Zope3-Checkins mailing list