[Zope3-checkins] CVS: Zope3/src/zope/app/i18n/tests - __init__.py:1.2 testi18ndirectives.py:1.2

Jim Fulton jim@zope.com
Wed, 25 Dec 2002 09:13:54 -0500


Update of /cvs-repository/Zope3/src/zope/app/i18n/tests
In directory cvs.zope.org:/tmp/cvs-serv15352/src/zope/app/i18n/tests

Added Files:
	__init__.py testi18ndirectives.py 
Log Message:
Grand renaming:

- Renamed most files (especially python modules) to lower case.

- Moved views and interfaces into separate hierarchies within each
  project, where each top-level directory under the zope package
  is a separate project.

- Moved everything to src from lib/python.

  lib/python will eventually go away. I need access to the cvs
  repository to make this happen, however.

There are probably some bits that are broken. All tests pass
and zope runs, but I haven't tried everything. There are a number
of cleanups I'll work on tomorrow.



=== Zope3/src/zope/app/i18n/tests/__init__.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:13:54 2002
+++ Zope3/src/zope/app/i18n/tests/__init__.py	Wed Dec 25 09:12:53 2002
@@ -0,0 +1,2 @@
+#
+# This file is necessary to make this directory a package.


=== Zope3/src/zope/app/i18n/tests/testi18ndirectives.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:13:54 2002
+++ Zope3/src/zope/app/i18n/tests/testi18ndirectives.py	Wed Dec 25 09:12:53 2002
@@ -0,0 +1,78 @@
+##############################################################################
+#
+# 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 os
+import unittest
+
+from cStringIO import StringIO
+
+from zope.component.tests.placelesssetup import PlacelessSetup
+from zope.configuration.xmlconfig import xmlconfig, Context, XMLConfig
+from zope.configuration.exceptions import ConfigurationError
+
+import zope.app.i18n
+import zope.i18n.tests
+
+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('meta.zcml', zope.app.i18n)()
+
+    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():
+    return unittest.makeSuite(DirectivesTest)
+
+if __name__ == '__main__':
+    unittest.TextTestRunner().run(test_suite())