[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/tests - testI18nDirectives.py:1.2 PlacelessSetup.py:1.3

Jim Fulton jim@zope.com
Tue, 19 Nov 2002 18:25:46 -0500


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

Modified Files:
	PlacelessSetup.py 
Added Files:
	testI18nDirectives.py 
Log Message:

Two changes that were far reaching and interdependent.

- Changed existing directives that mention interfaces to register
  those interfaces with the global interface service.

- Moved all configuration support (except that in Zope.Configuration)
  into Zope.App. This was necessary to get the order of execution such
  that the interface service was defined before directives that used
  interfaces were used.  This is a change that has been needed for
  some time.



=== Zope3/lib/python/Zope/App/tests/testI18nDirectives.py 1.1 => 1.2 ===
--- /dev/null	Tue Nov 19 18:25:46 2002
+++ Zope3/lib/python/Zope/App/tests/testI18nDirectives.py	Tue Nov 19 18:25:15 2002
@@ -0,0 +1,77 @@
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+# 
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+# 
+##############################################################################
+"""Test the gts ZCML namespace directives.
+
+$Id$
+"""
+import unittest
+import os
+from cStringIO import StringIO
+
+from Zope.Configuration.xmlconfig import xmlconfig, Context, XMLConfig
+from Zope.Configuration.Exceptions import ConfigurationError
+
+from Zope.ComponentArchitecture.tests.PlacelessSetup import PlacelessSetup
+
+import Zope.App
+from Zope.I18n.GlobalTranslationService import translationService 
+
+template = """<zopeConfigure
+   xmlns='http://namespaces.zope.org/zope'
+   xmlns:gts='http://namespaces.zope.org/gts'>
+   xmlns:test='http://www.zope.org/NS/Zope3/test'>
+   %s
+   </zopeConfigure>"""
+
+
+class DirectivesTest(PlacelessSetup, unittest.TestCase):
+
+    # XXX: tests for other directives needed
+
+    def setUp(self):
+        PlacelessSetup.setUp(self)
+        XMLConfig('i18n-meta.zcml', Zope.App)()
+
+    def testRegisterTranslations(self):
+        eq = self.assertEqual
+        eq(translationService._catalogs, {})
+        xmlconfig(StringIO(template % (
+            '''
+            <gts:registerTranslations directory="./locale" />
+            '''
+            )), None, Context([], Zope.I18n.tests)) 
+        path = os.path.join(Context([], Zope.I18n.tests).path(),
+                            'locale', 'en',
+                            'LC_MESSAGES', 'Zope-I18n.mo')
+        eq(translationService._catalogs,
+           {('en', 'Zope-I18n'): [unicode(path)]})
+
+    def testDefaultLanguages(self):
+        eq = self.assertEqual
+        eq(translationService._fallbacks, ['en'])
+        xmlconfig(StringIO(template % (
+            '''
+            <gts:defaultLanguages languages="de nl xx" />
+            '''
+            )), None, Context([], Zope.I18n.tests))
+        eq(translationService._fallbacks, ['de', 'nl', 'xx'])
+
+
+def test_suite():
+    loader=unittest.TestLoader()
+    return loader.loadTestsFromTestCase(DirectivesTest)
+
+if __name__=='__main__':
+    unittest.TextTestRunner().run(test_suite())
+


=== Zope3/lib/python/Zope/App/tests/PlacelessSetup.py 1.2 => 1.3 ===
--- Zope3/lib/python/Zope/App/tests/PlacelessSetup.py:1.2	Fri Oct  4 16:07:09 2002
+++ Zope3/lib/python/Zope/App/tests/PlacelessSetup.py	Tue Nov 19 18:25:15 2002
@@ -19,12 +19,15 @@
 
 from Zope.ComponentArchitecture.tests.PlacelessSetup \
      import PlacelessSetup as CAPlacelessSetup
+from Zope.App.ComponentArchitecture.tests.PlacelessSetup \
+     import PlacelessSetup as ACAPlacelessSetup
 from Zope.Event.tests.PlacelessSetup \
      import PlacelessSetup as EventPlacelessSetup
 
 
-class PlacelessSetup(CAPlacelessSetup, EventPlacelessSetup):
+class PlacelessSetup(CAPlacelessSetup, ACAPlacelessSetup, EventPlacelessSetup):
 
     def setUp(self):
         CAPlacelessSetup.setUp(self)
+        ACAPlacelessSetup.setUp(self)
         EventPlacelessSetup.setUp(self)