[Zope3-checkins] CVS: Zope3/src/zope/i18n/tests - __init__.py:1.2 de-default.mo:1.2 de-default.po:1.2 en-default.mo:1.2 en-default.po:1.2 test_gettextmessagecatalog.py:1.2 test_globaltranslationservice.py:1.2 test_ireadmessagecatalog.py:1.2 test_ireadtranslationservice.py:1.2 test_isynctranslationservice.py:1.2 test_iwritemessagecatalog.py:1.2 test_iwritetranslationservice.py:1.2 test_negotiator.py:1.2 test_simpletranslationservice.py:1.2 testi18nawareobject.py:1.2 testii18naware.py:1.2

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


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

Added Files:
	__init__.py de-default.mo de-default.po en-default.mo 
	en-default.po test_gettextmessagecatalog.py 
	test_globaltranslationservice.py test_ireadmessagecatalog.py 
	test_ireadtranslationservice.py 
	test_isynctranslationservice.py test_iwritemessagecatalog.py 
	test_iwritetranslationservice.py test_negotiator.py 
	test_simpletranslationservice.py testi18nawareobject.py 
	testii18naware.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/i18n/tests/__init__.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:14:11 2002
+++ Zope3/src/zope/i18n/tests/__init__.py	Wed Dec 25 09:13:40 2002
@@ -0,0 +1,2 @@
+#
+# This file is necessary to make this directory a package.


=== Zope3/src/zope/i18n/tests/de-default.mo 1.1 => 1.2 ===


=== Zope3/src/zope/i18n/tests/de-default.po 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:14:11 2002
+++ Zope3/src/zope/i18n/tests/de-default.po	Wed Dec 25 09:13:40 2002
@@ -0,0 +1,14 @@
+msgid ""
+msgstr ""
+"Project-Id-Version: Zope 3\n"
+"PO-Revision-Date: 2002/06/13\n"
+"Last-Translator: Zope 3 contributors\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=ISO-8859-1\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+msgid "short_greeting"
+msgstr "Hallo!"
+
+msgid "greeting"
+msgstr "Hallo $name, wie geht es Dir?"


=== Zope3/src/zope/i18n/tests/en-default.mo 1.1 => 1.2 ===


=== Zope3/src/zope/i18n/tests/en-default.po 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:14:12 2002
+++ Zope3/src/zope/i18n/tests/en-default.po	Wed Dec 25 09:13:40 2002
@@ -0,0 +1,14 @@
+msgid ""
+msgstr ""
+"Project-Id-Version: Zope 3\n"
+"PO-Revision-Date: 2002/06/13\n"
+"Last-Translator: Zope 3 contributors\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=ISO-8859-1\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+msgid "short_greeting"
+msgstr "Hello!"
+
+msgid "greeting"
+msgstr "Hello $name, how are you?"


=== Zope3/src/zope/i18n/tests/test_gettextmessagecatalog.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:14:12 2002
+++ Zope3/src/zope/i18n/tests/test_gettextmessagecatalog.py	Wed Dec 25 09:13:40 2002
@@ -0,0 +1,44 @@
+##############################################################################
+#
+# 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 a gettext implementation of a Message Catalog.
+
+$Id$
+"""
+import unittest, sys, os
+from zope.i18n.gettextmessagecatalog import GettextMessageCatalog
+from zope.i18n.tests.test_ireadmessagecatalog import TestIReadMessageCatalog
+
+
+class GettextMessageCatalogTest(TestIReadMessageCatalog):
+
+
+    def _getMessageCatalog(self):
+        from zope.i18n import tests
+        path = os.path.split(tests.__file__)[0]
+        self._path = os.path.join(path, 'en-default.mo')
+        catalog = GettextMessageCatalog('en', 'default', self._path)
+        return catalog
+
+
+    def _getUniqueIndentifier(self):
+        return self._path
+
+
+
+def test_suite():
+    loader=unittest.TestLoader()
+    return loader.loadTestsFromTestCase(GettextMessageCatalogTest)
+
+if __name__=='__main__':
+    unittest.TextTestRunner().run(test_suite())


=== Zope3/src/zope/i18n/tests/test_globaltranslationservice.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:14:12 2002
+++ Zope3/src/zope/i18n/tests/test_globaltranslationservice.py	Wed Dec 25 09:13:40 2002
@@ -0,0 +1,81 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""This module tests the regular persistent Translation Service.
+
+$Id$
+"""
+import unittest, sys, os
+from zope.i18n.globaltranslationservice import GlobalTranslationService
+from zope.i18n.gettextmessagecatalog import GettextMessageCatalog
+from zope.i18n.tests.test_ireadtranslationservice import TestIReadTranslationService, \
+     Environment
+
+def testdir():
+    from zope.i18n import tests
+    return os.path.dirname(tests.__file__)
+
+
+class TestGlobalTranslationService(TestIReadTranslationService):
+
+    def _getTranslationService(self):
+        service = GlobalTranslationService('default')
+        path = testdir()
+        en_catalog = GettextMessageCatalog('en', 'default',
+                                           os.path.join(path, 'en-default.mo'))
+        de_catalog = GettextMessageCatalog('de', 'default',
+                                           os.path.join(path, 'de-default.mo'))
+        service.addCatalog(en_catalog)
+        service.addCatalog(de_catalog)
+        return service
+
+    def testSimpleNoTranslate(self):
+        translate = self._service.translate
+        raises = self.assertRaises
+        eq = self.assertEqual
+        # Unset fallback translation languages
+        self._service.setLanguageFallbacks([])
+        # Test that we have at least the minimum required arguments
+        raises(TypeError, translate, 'Hello')
+        # Test that a translation in an unsupported language returns the
+        # original message id unchanged, if there is no fallback language
+        eq(translate('default', 'short_greeting', target_language='es'),
+           'short_greeting')
+        # Same test, but use the context argument instead of target_language
+        context = Environment()
+        eq(translate('default', 'short_greeting', context=context),
+           'short_greeting')
+        # Test that at least one of context or target_language is given
+        raises(TypeError, translate, 'short_greeting', context=None)
+
+    def testSimpleFallbackTranslation(self):
+        translate = self._service.translate
+        raises = self.assertRaises
+        eq = self.assertEqual
+        # Test that a translation in an unsupported language returns a
+        # translation in the fallback language (by default, English)
+        eq(translate('default', 'short_greeting', target_language='es'),
+           u'Hello!')
+        # Same test, but use the context argument instead of target_language
+        context = Environment()
+        eq(translate('default', 'short_greeting', context=context),
+           u'Hello!')
+
+
+def test_suite():
+    loader = unittest.TestLoader()
+    return loader.loadTestsFromTestCase(TestGlobalTranslationService)
+
+
+if __name__ == '__main__':
+    unittest.TextTestRunner().run(test_suite())


=== Zope3/src/zope/i18n/tests/test_ireadmessagecatalog.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:14:12 2002
+++ Zope3/src/zope/i18n/tests/test_ireadmessagecatalog.py	Wed Dec 25 09:13:40 2002
@@ -0,0 +1,68 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""This is an 'abstract' test for the IMessageCatalog interface.
+
+$Id$
+"""
+import unittest
+from zope.interface.verify import verifyObject
+from zope.interfaces.i18n import IReadMessageCatalog
+
+
+class TestIReadMessageCatalog(unittest.TestCase):
+
+
+    # This should be overwritten by every class that inherits this test
+    def _getMessageCatalog(self):
+        pass
+
+    def _getUniqueIndentifier(self):
+        pass
+
+
+    def setUp(self):
+        self._catalog = self._getMessageCatalog()
+        assert verifyObject(IReadMessageCatalog, self._catalog)
+
+
+    def testGetMessage(self):
+        catalog = self._catalog
+        self.assertEqual(catalog.getMessage('short_greeting'), 'Hello!')
+        self.assertRaises(KeyError, catalog.getMessage, 'foo')
+
+
+    def testQueryMessage(self):
+        catalog = self._catalog
+        self.assertEqual(catalog.queryMessage('short_greeting'), 'Hello!')
+        self.assertEqual(catalog.queryMessage('foo'), None)
+        self.assertEqual(catalog.queryMessage('foo', 'bar'), 'bar')
+
+
+    def testGetLanguage(self):
+        catalog = self._catalog
+        self.assertEqual(catalog.getLanguage(), 'en')
+
+
+    def testGetDomain(self):
+        catalog = self._catalog
+        self.assertEqual(catalog.getDomain(), 'default')
+
+
+    def testGetIdentifier(self):
+        catalog = self._catalog
+        self.assertEqual(catalog.getIdentifier(), self._getUniqueIndentifier())
+
+
+def test_suite():
+    return unittest.TestSuite() # Deliberatly empty


=== Zope3/src/zope/i18n/tests/test_ireadtranslationservice.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:14:12 2002
+++ Zope3/src/zope/i18n/tests/test_ireadtranslationservice.py	Wed Dec 25 09:13:40 2002
@@ -0,0 +1,125 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""This is an 'abstract' test for the ITranslationService interface.
+
+$Id$
+"""
+
+import unittest
+from zope.interface.verify import verifyObject
+from zope.component.tests.placelesssetup import PlacelessSetup
+
+# XXX Bad, can't depend on app!
+from zope.app.component.metaconfigure import provideService, managerHandler
+from zope.i18n.negotiator import negotiator
+from zope.interfaces.i18n import INegotiator
+from zope.interfaces.i18n import IUserPreferredLanguages
+from zope.interfaces.i18n import IReadTranslationService
+from zope.interfaces.i18n import IDomain
+
+
+class Environment:
+
+    __implements__ = IUserPreferredLanguages
+
+    def __init__(self, langs=()):
+        self.langs = langs
+
+    def getPreferredLanguages(self):
+        return self.langs
+
+
+
+class TestIReadTranslationService(PlacelessSetup, unittest.TestCase):
+
+    # This should be overwritten by every clas that inherits this test
+    def _getTranslationService(self):
+        pass
+
+    def setUp(self):
+        PlacelessSetup.setUp(self)
+        self._service = self._getTranslationService()
+        assert verifyObject(IReadTranslationService, self._service)
+        # Setup the negotiator service registry entry
+        managerHandler('defineService', 'LanguageNegotiation', INegotiator)
+        provideService('LanguageNegotiation', negotiator, 'zope.Public')
+
+    # I know, I know. This is not part of the interface, but it is implemented
+    # in every Translation Service, so it fits well here.
+    def testInterpolation(self):
+        service = self._service
+        interp = service.interpolate
+        eq = self.assertEqual
+        mapping = {'name': 'Zope', 'version': '3x'}
+        # Test simple interpolations
+        eq(interp('This is $name.', mapping), 'This is Zope.')
+        eq(interp('This is ${name}.', mapping), 'This is Zope.')
+        # Test more than one interpolation variable
+        eq(interp('This is $name version $version.', mapping),
+           'This is Zope version 3x.')
+        eq(interp('This is ${name} version $version.', mapping),
+           'This is Zope version 3x.')
+        eq(interp('This is $name version ${version}.', mapping),
+           'This is Zope version 3x.')
+        eq(interp('This is ${name} version ${version}.', mapping),
+           'This is Zope version 3x.')
+        # Test escaping the $
+        eq(interp('This is $$name.', mapping), 'This is $$name.')
+        eq(interp('This is $${name}.', mapping), 'This is $${name}.')
+
+    def testSimpleTranslate(self):
+        translate = self._service.translate
+        eq = self.assertEqual
+        # Test that a given message id is properly translated in a supported
+        # language
+        eq(translate('default', 'short_greeting', target_language='de'),
+           'Hallo!')
+        # Same test, but use the context argument
+        context = Environment(('de', 'en'))
+        eq(translate('default', 'short_greeting', context=context),
+           'Hallo!')
+
+    def testDynamicTranslate(self):
+        translate = self._service.translate
+        eq = self.assertEqual
+        # Testing both translation and interpolation
+        eq(translate('default', 'greeting', mapping={'name': 'Stephan'},
+                     target_language='de'),
+           'Hallo Stephan, wie geht es Dir?')
+
+    def testGetDomain(self):
+        service = self._service
+        domain = service.getDomain('default')
+        self.assertEqual(verifyObject(IDomain, domain), 1)
+
+    def testDomainTranslate(self):
+        service = self._service
+        domain = service.getDomain('default')
+        translate = domain.translate
+        eq = self.assertEqual
+        # target language argument
+        eq(translate('short_greeting', target_language='de'), 'Hallo!')
+        # context argument
+        context = Environment(('de', 'en'))
+        eq(translate('short_greeting', context=context), 'Hallo!')
+
+    def testNoTranslation(self):
+        translate = self._service.translate
+        eq = self.assertEqual
+        # Test that an unknown message id returns None as a translation
+        eq(translate('default', 'glorp_smurf_hmpf', target_language='en'),
+           None)
+
+def test_suite():
+    return unittest.TestSuite() # Deliberatly empty


=== Zope3/src/zope/i18n/tests/test_isynctranslationservice.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:14:12 2002
+++ Zope3/src/zope/i18n/tests/test_isynctranslationservice.py	Wed Dec 25 09:13:40 2002
@@ -0,0 +1,108 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""This is an 'abstract' test for the Synchronization Support interface.
+
+$Id$
+"""
+
+import unittest
+from zope.interface.verify import verifyObject
+from zope.component.tests.placelesssetup import PlacelessSetup
+from zope.interfaces.i18n import ISyncTranslationService
+
+
+class TestISyncTranslationService(PlacelessSetup, unittest.TestCase):
+
+
+    foreign_messages = [
+        # Message that is not locally available
+        {'domain': 'default', 'language': 'en', 'msgid': 'test',
+         'msgstr': 'Test', 'mod_time': 0},
+        # This message is newer than the local one.
+        {'domain': 'default', 'language': 'de', 'msgid': 'short_greeting',
+         'msgstr': 'Hallo.', 'mod_time': 20},
+        # This message is older than the local one.
+        {'domain': 'default', 'language': 'en', 'msgid': 'short_greeting',
+         'msgstr': 'Hello', 'mod_time': 0},
+        # This message is up-to-date.
+        {'domain': 'default', 'language': 'en', 'msgid': 'greeting',
+         'msgstr': 'Hello $name, how are you?', 'mod_time': 0}]
+
+
+    local_messages = [
+        # This message is older than the foreign one.
+        {'domain': 'default', 'language': 'de', 'msgid': 'short_greeting',
+         'msgstr': 'Hallo!', 'mod_time': 10},
+        # This message is newer than the foreign one.
+        {'domain': 'default', 'language': 'en', 'msgid': 'short_greeting',
+         'msgstr': 'Hello!', 'mod_time': 10},
+        # This message is up-to-date.
+        {'domain': 'default', 'language': 'en', 'msgid': 'greeting',
+         'msgstr': 'Hello $name, how are you?', 'mod_time': 0},
+        # This message is only available locally.
+        {'domain': 'default', 'language': 'de', 'msgid': 'greeting',
+         'msgstr': 'Hallo $name, wie geht es Dir?', 'mod_time': 0},
+        ]
+
+
+    # This should be overwritten by every clas that inherits this test
+    def _getTranslationService(self):
+        pass
+
+
+    def setUp(self):
+        PlacelessSetup.setUp(self)
+        self._service = self._getTranslationService()
+        assert verifyObject(ISyncTranslationService, self._service)
+
+
+    def testGetMessagesMapping(self):
+        mapping = self._service.getMessagesMapping(['default'], ['de', 'en'],
+                                                  self.foreign_messages)
+        self.assertEqual(mapping[('test', 'default', 'en')],
+                         (self.foreign_messages[0], None))
+        self.assertEqual(mapping[('short_greeting', 'default', 'de')],
+                         (self.foreign_messages[1], self.local_messages[0]))
+        self.assertEqual(mapping[('short_greeting', 'default', 'en')],
+                         (self.foreign_messages[2], self.local_messages[1]))
+        self.assertEqual(mapping[('greeting', 'default', 'en')],
+                         (self.foreign_messages[3], self.local_messages[2]))
+        self.assertEqual(mapping[('greeting', 'default', 'de')],
+                         (None, self.local_messages[3]))
+
+
+    def testSynchronize(self):
+        service = self._service
+        mapping = service.getMessagesMapping(['default'], ['de', 'en'],
+                                             self.foreign_messages)
+        service.synchronize(mapping)
+
+        self.assertEqual(service.getMessage('test', 'default', 'en'),
+                         self.foreign_messages[0])
+        self.assertEqual(service.getMessage('short_greeting', 'default', 'de'),
+                         self.foreign_messages[1])
+        self.assertEqual(service.getMessage('short_greeting', 'default', 'en'),
+                         self.local_messages[1])
+        self.assertEqual(service.getMessage('greeting', 'default', 'en'),
+                         self.local_messages[2])
+        self.assertEqual(service.getMessage('greeting', 'default', 'en'),
+                         self.foreign_messages[3])
+        self.assertEqual(service.getMessage('greeting', 'default', 'de'),
+                         None)
+
+
+
+
+def test_suite():
+    return unittest.TestSuite() # Deliberatly empty


=== Zope3/src/zope/i18n/tests/test_iwritemessagecatalog.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:14:12 2002
+++ Zope3/src/zope/i18n/tests/test_iwritemessagecatalog.py	Wed Dec 25 09:13:40 2002
@@ -0,0 +1,86 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""This is an 'abstract' test for the IMessageCatalog interface.
+
+$Id$
+"""
+
+import unittest
+from zope.interface.verify import verifyObject
+from zope.interfaces.i18n import IWriteMessageCatalog
+
+
+class TestIWriteMessageCatalog(unittest.TestCase):
+
+
+    # This should be overwritten by every class that inherits this test
+    def _getMessageCatalog(self):
+        pass
+
+    def _getUniqueIndentifier(self):
+        pass
+
+
+    def setUp(self):
+        self._catalog = self._getMessageCatalog()
+        assert verifyObject(IWriteMessageCatalog, self._catalog)
+
+
+    def testGetFullMessage(self):
+        catalog = self._catalog
+        self.assertEqual(catalog.getFullMessage('short_greeting'),
+                         {'domain': 'default',
+                          'language': 'en',
+                          'msgid': 'short_greeting',
+                          'msgstr': 'Hello!',
+                          'mod_time': 0})
+
+
+    def testSetMessage(self):
+        catalog = self._catalog
+        catalog.setMessage('test', 'Test', 1)
+        self.assertEqual(catalog.getFullMessage('test'),
+                         {'domain': 'default',
+                          'language': 'en',
+                          'msgid': 'test',
+                          'msgstr': 'Test',
+                          'mod_time': 1})
+        catalog.deleteMessage('test')
+
+
+    def testDeleteMessage(self):
+        catalog = self._catalog
+        self.assertEqual(catalog.queryMessage('test'), None)
+        catalog.setMessage('test', 'Test', 1)
+        self.assertEqual(catalog.queryMessage('test'), 'Test')
+        catalog.deleteMessage('test')
+        self.assertEqual(catalog.queryMessage('test'), None)
+
+
+    def testGetMessageIds(self):
+        catalog = self._catalog
+        ids = catalog.getMessageIds()
+        ids.sort()
+        self.assertEqual(ids, ['greeting', 'short_greeting'])
+
+
+    def testGetMessages(self):
+        catalog = self._catalog
+        ids = catalog.getMessageIds()
+        ids.sort()
+        self.assertEqual(ids, ['greeting', 'short_greeting'])
+
+
+def test_suite():
+    return unittest.TestSuite() # Deliberatly empty


=== Zope3/src/zope/i18n/tests/test_iwritetranslationservice.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:14:12 2002
+++ Zope3/src/zope/i18n/tests/test_iwritetranslationservice.py	Wed Dec 25 09:13:40 2002
@@ -0,0 +1,157 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""This is an 'abstract' test for the ITranslationService interface.
+
+$Id$
+"""
+
+import unittest
+
+from zope.interface.verify import verifyObject
+from zope.component.tests.placelesssetup import PlacelessSetup
+
+# XXX Bad, can't depend on app!
+from zope.app.component.metaconfigure import provideService, managerHandler
+
+from zope.i18n.negotiator import negotiator
+from zope.interfaces.i18n import INegotiator
+from zope.interfaces.i18n import IUserPreferredLanguages
+from zope.interfaces.i18n import ITranslationService
+from zope.interfaces.i18n import IDomain
+
+class Environment:
+
+    __implements__ = IUserPreferredLanguages
+
+    def __init__(self, langs=()):
+        self.langs = langs
+
+    def getPreferredLanguages(self):
+        return self.langs
+
+
+
+class TestIWriteTranslationService(PlacelessSetup, unittest.TestCase):
+
+    def _getTranslationService(self):
+        """This should be overwritten by every clas that inherits this test.
+
+           We expect the TranslationService to contain exactly 2 languages:
+           de and en
+        """
+
+
+    def setUp(self):
+        PlacelessSetup.setUp(self)
+        self._service = self._getTranslationService()
+        assert verifyObject(ITranslationService, self._service)
+        managerHandler('defineService', 'Translation',
+                       ITranslationService)
+        provideService('Translation', self._service, 'zope.Public')
+
+        # Setup the negotiator service registry entry
+        managerHandler('defineService', 'LanguageNegotiation', INegotiator)
+        provideService('LanguageNegotiation', negotiator, 'zope.Public')
+
+
+    def _getDomains(self, service):
+        domains = service.getAllDomains()
+        domains.sort()
+        return domains
+
+
+    def testGetAddDeleteDomain(self):
+        service = self._service
+        service.addLanguage('de')
+        d = self._getDomains(service)
+        self.assertEqual(service.getAllDomains(), d+[])
+        service.addDomain('test')
+        self.assertEqual(service.getAllDomains(), d+['test'])
+        service.addDomain('test2')
+        self.assertEqual(service.getAllDomains(), d+['test', 'test2'])
+        self.assertEqual(service.getAvailableDomains('de'),
+                         d+['test', 'test2'])
+        service.deleteDomain('test')
+        self.assertEqual(service.getAllDomains(), d+['test2'])
+        service.deleteDomain('test2')
+        self.assertEqual(service.getAllDomains(), d+[])
+
+
+    def _getLanguages(self, service):
+        languages = service.getAllLanguages()
+        languages.sort()
+        return languages
+
+
+    def testGetAddDeleteLanguage(self):
+        service = self._service
+        service.addDomain('test')
+        langs = self._getLanguages(service)
+        service.addLanguage('es')
+        self.assertEqual(self._getLanguages(service), langs+['es'])
+        service.addLanguage('fr')
+        self.assertEqual(self._getLanguages(service), langs+['es', 'fr'])
+        self.assertEqual(service.getAvailableLanguages('test'),
+                         langs+['es', 'fr'])
+        service.deleteLanguage('es')
+        self.assertEqual(self._getLanguages(service), langs+['fr'])
+        service.deleteLanguage('fr')
+        self.assertEqual(self._getLanguages(service), langs)
+
+
+    def testAddUpdateDeleteMessage(self):
+        service = self._service
+        self.assertEqual(service.translate('test', 'greeting',
+                                           target_language='de'), 'greeting')
+        service.addMessage('test', 'greeting', 'Hallo!', 'de')
+        self.assertEqual(service.translate('test', 'greeting',
+                                           target_language='de'), 'Hallo!')
+        service.updateMessage('test', 'greeting', 'Hallo Ihr da!', 'de')
+        self.assertEqual(service.translate('test', 'greeting',
+                                           target_language='de'),
+                         'Hallo Ihr da!')
+        service.deleteMessage('test', 'greeting', 'de')
+        self.assertEqual(service.translate('test', 'greeting',
+                                           target_language='de'), None)
+
+
+    def _getMessageIds(self, service, domain, filter="%"):
+        ids = service.getMessageIdsOfDomain(domain, filter)
+        ids.sort()
+        return ids
+
+
+    def testFilteredGetAllMessageIdsOfDomain(self):
+        service = self._service
+        service.addMessage('test',  'greeting', 'Greeting!', 'en')
+        service.addMessage('test',  'greeting2', 'Greeting 2!', 'en')
+        service.addMessage('test2', 'greeting3', 'Greeting 3!', 'en')
+        service.addMessage('test2', 'greeting4', 'Greeting 4!', 'en')
+
+        self.assertEqual(self._getMessageIds(service, 'test'),
+                         ['greeting', 'greeting2'])
+        self.assertEqual(self._getMessageIds(service, 'test2'),
+                         ['greeting3', 'greeting4'])
+        self.assertEqual(self._getMessageIds(service, 'test', 'greeting'),
+                         ['greeting', 'greeting2'])
+        self.assertEqual(self._getMessageIds(service, 'test', '%2'),
+                         ['greeting2'])
+        self.assertEqual(self._getMessageIds(service, 'test', 'gre%2'),
+                         ['greeting2'])
+        self.assertEqual(self._getMessageIds(service, 'test2', 'gre%'),
+                         ['greeting3', 'greeting4'])
+
+
+def test_suite():
+    return unittest.TestSuite() # Deliberatly empty


=== Zope3/src/zope/i18n/tests/test_negotiator.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:14:12 2002
+++ Zope3/src/zope/i18n/tests/test_negotiator.py	Wed Dec 25 09:13:40 2002
@@ -0,0 +1,58 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""
+
+$Id$
+"""
+import unittest, sys
+
+from zope.i18n.negotiator import Negotiator
+from zope.interfaces.i18n import IUserPreferredLanguages
+from zope.component.tests.placelesssetup import PlacelessSetup
+
+class Env:
+    __implements__ = IUserPreferredLanguages
+
+    def __init__(self, langs=()):
+        self.langs = langs
+
+    def getPreferredLanguages(self):
+        return self.langs
+
+
+class Test(PlacelessSetup, unittest.TestCase):
+    def setUp(self):
+        PlacelessSetup.setUp(self)
+        self.Negotiator = Negotiator()
+
+    def test1(self):
+
+        _cases = (
+            (('en','de'), ('en','de','fr'),  'en'),
+            (('en'),      ('it','de','fr'),  None)
+            )
+
+        for user_pref_langs, obj_langs, expected in _cases:
+            env = Env(user_pref_langs)
+            self.assertEqual(self.Negotiator.getLanguage(obj_langs, env),
+                             expected)
+
+
+def test_suite():
+    loader = unittest.TestLoader()
+    return loader.loadTestsFromTestCase(Test)
+
+
+if __name__ == '__main__':
+    unittest.TextTestRunner().run(test_suite())


=== Zope3/src/zope/i18n/tests/test_simpletranslationservice.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:14:12 2002
+++ Zope3/src/zope/i18n/tests/test_simpletranslationservice.py	Wed Dec 25 09:13:40 2002
@@ -0,0 +1,40 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""This module tests the regular persistent Translation Service.
+
+$Id$
+"""
+import unittest
+from zope.i18n.simpletranslationservice import SimpleTranslationService
+from zope.i18n.tests.test_ireadtranslationservice import TestIReadTranslationService
+
+
+class TestSimpleTranslationService(TestIReadTranslationService):
+
+    def _getTranslationService(self):
+        service = SimpleTranslationService(
+            {('default', 'en', 'short_greeting'): 'Hello!',
+             ('default', 'de', 'short_greeting'): 'Hallo!',
+             ('default', 'en', 'greeting'): 'Hello $name, how are you?',
+             ('default', 'de', 'greeting'): 'Hallo $name, wie geht es Dir?'}
+            )
+        return service
+
+
+def test_suite():
+    loader = unittest.TestLoader()
+    return loader.loadTestsFromTestCase(TestSimpleTranslationService)
+
+if __name__ == '__main__':
+    unittest.TextTestRunner().run(test_suite())


=== Zope3/src/zope/i18n/tests/testi18nawareobject.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:14:12 2002
+++ Zope3/src/zope/i18n/tests/testi18nawareobject.py	Wed Dec 25 09:13:40 2002
@@ -0,0 +1,89 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""This is a test for the II18nAware interface.
+
+$Id$
+"""
+import unittest
+from zope.interface.verify import verifyObject
+from zope.interfaces.i18n import II18nAware
+from zope.i18n.tests.testii18naware import TestII18nAware
+
+
+class I18nAwareContentObject:
+
+    __implements__ = II18nAware
+
+    def __init__(self):
+        self.content = {}
+        self.defaultLanguage = 'en'
+
+    def getContent(self, language):
+        return self.content[language]
+
+    def queryContent(self, language, default=None):
+        return self.content.get(language, default)
+
+    def setContent(self, content, language):
+        self.content[language] = content
+
+    ############################################################
+    # Implementation methods for interface
+    # II18nAware.py
+
+    def getDefaultLanguage(self):
+        'See II18nAware'
+        return self.defaultLanguage
+
+    def setDefaultLanguage(self, language):
+        'See II18nAware'
+        self.defaultLanguage = language
+
+    def getAvailableLanguages(self):
+        'See II18nAware'
+        return self.content.keys()
+
+    #
+    ############################################################
+
+
+class TestI18nAwareObject(TestII18nAware):
+
+    def _createObject(self):
+        object = I18nAwareContentObject()
+        object.setContent('English', 'en')
+        object.setContent('Lithuanian', 'lt')
+        object.setContent('French', 'fr')
+        return object
+
+    def testSetContent(self):
+        self.object.setContent('German', 'de')
+        self.assertEqual(self.object.content['de'], 'German')
+
+    def testGetContent(self):
+        self.assertEqual(self.object.getContent('en'), 'English')
+        self.assertRaises(KeyError, self.object.getContent, 'es')
+
+    def testQueryContent(self):
+        self.assertEqual(self.object.queryContent('en'), 'English')
+        self.assertEqual(self.object.queryContent('es', 'N/A'), 'N/A')
+
+
+def test_suite():
+    loader = unittest.TestLoader()
+    return loader.loadTestsFromTestCase(TestI18nAwareObject)
+
+
+if __name__ == '__main__':
+    unittest.TextTestRunner().run(test_suite())


=== Zope3/src/zope/i18n/tests/testii18naware.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:14:12 2002
+++ Zope3/src/zope/i18n/tests/testii18naware.py	Wed Dec 25 09:13:40 2002
@@ -0,0 +1,51 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""This is a test for the II18nAware interface.
+
+$Id$
+"""
+import unittest
+from zope.interface.verify import verifyObject
+from zope.interfaces.i18n import II18nAware
+
+
+def sorted(list):
+    list.sort()
+    return list
+
+
+class TestII18nAware(unittest.TestCase):
+
+    def setUp(self):
+        self.object = self._createObject()
+        self.object.setDefaultLanguage('fr')
+
+    def _createObject(self):
+        # Should create an object that has lt, en and fr as available
+        # languages
+        pass
+
+    def testGetDefaultLanguage(self):
+        self.assertEqual(self.object.getDefaultLanguage(), 'fr')
+
+    def testSetDefaultLanguage(self):
+        self.object.setDefaultLanguage('lt')
+        self.assertEqual(self.object.getDefaultLanguage(), 'lt')
+
+    def testGetAvailableLanguages(self):
+        self.assertEqual(sorted(self.object.getAvailableLanguages()), ['en', 'fr', 'lt'])
+
+
+def test_suite():
+    return unittest.TestSuite() # Deliberatly empty