[Zope-Checkins] CVS: Zope3/lib/python/Zope/I18n/tests - testTranslationService.py:1.1.2.2

Stephan Richter srichter@cbu.edu
Wed, 5 Jun 2002 17:07:31 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/I18n/tests
In directory cvs.zope.org:/tmp/cvs-serv23992/tests

Modified Files:
      Tag: Zope-3x-branch
	testTranslationService.py 
Log Message:
Well folks, here it is. The first working cut of the TranslationService.

I dunno whether the ZCML is correct at this point in time, but I want to 
wait until Wonderland lands. I still have to finish the Domain and 
BrowserLanguage getter. I also plan some sort of internationalized object
converter that will do some monatary, date-time and other local 
conversions.

But what does work? The Langauge Negotiater works just fine. The simple 
MessageCatalog too. Of course the TranslationService does its thing. I need
to write some more unit tests though.


=== Zope3/lib/python/Zope/I18n/tests/testTranslationService.py 1.1.2.1 => 1.1.2.2 ===
 ##############################################################################
 import unittest, sys
+from Zope.ComponentArchitecture.tests.PlacelessSetup import PlacelessSetup
 from Zope.I18n.IUserPreferedLanguages import IUserPreferedLanguages
 from Zope.I18n.TranslationService import TranslationService
 from Zope.I18n.MessageCatalog import MessageCatalog 
@@ -29,7 +30,7 @@
         return self.langs
 
 
-class TestTranslationService(unittest.TestCase):
+class TestTranslationService(PlacelessSetup, unittest.TestCase):
 
 
     def testInterpolation(self):
@@ -58,6 +59,7 @@
 
     def setUp(self):
         ''' '''
+        PlacelessSetup.setUp(self)
         self._service = TranslationService('default') 
 
         en_catalog = MessageCatalog('en', 'default')
@@ -90,33 +92,24 @@
                           context=None)
     
     
+    def testSimpleTranslate(self):
+        ''' '''
+        service = self._service
+        self.assertEqual(service.translate('default', 'short_greeting',
+                                           target_language='de'),
+                         'Hallo!')
+
+    
+    def testDynamicTranslate(self):
+        ''' '''
+        service = self._service
     
-    #def testSimpleTranslate(self):
-    #    ''' '''
-    #    service = self._service
-    #    self.assertEqual(service.translate('Hello',
-    #                                       destination_language_tag='de'),
-    #                     'Hallo')
-    #
-    #
-    #def testSequenceTranslate(self):
-    #    ''' '''
-    #    service = self._service
-    #
-    #    self.assertEqual(list(service.translateSequence(('Hello',),
-    #                                       destination_language_tag='de')),
-    #                     ['Hallo'])
-    #
-    #
-    #def testDynamicSequenceTranslate(self):
-    #    ''' '''
-    #    service = self._service
-    #
-    #    self.assertEqual(list(service.translateSequence(
-    #        ('Hello ', Var('name'), ', how are you?'),
-    #        destination_language_tag='de', data={'name': 'Stephan'})),
-    #                     ['Hallo Stephan, wie geht es Dir?'])
-    #    
+        self.assertEqual(service.translate('default', 'greeting',
+                                           mapping={'name': 'Stephan'},
+                                           target_language='de'),
+                         'Hallo Stephan, wie geht es Dir?')
+        
+
 
 def test_suite():
     loader=unittest.TestLoader()
@@ -124,6 +117,3 @@
 
 if __name__=='__main__':
     unittest.TextTestRunner().run(test_suite())
-
-
-