[Zope3-checkins] CVS: Zope3/src/zope/app/i18n/tests - __init__.py:1.1.2.1 testi18ndirectives.py:1.1.2.1
Jim Fulton
jim@zope.com
Mon, 23 Dec 2002 14:31:38 -0500
Update of /cvs-repository/Zope3/src/zope/app/i18n/tests
In directory cvs.zope.org:/tmp/cvs-serv19908/zope/app/i18n/tests
Added Files:
Tag: NameGeddon-branch
__init__.py testi18ndirectives.py
Log Message:
Initial renaming before debugging
=== Added File Zope3/src/zope/app/i18n/tests/__init__.py ===
#
# This file is necessary to make this directory a package.
=== Added File Zope3/src/zope/app/i18n/tests/testi18ndirectives.py ===
##############################################################################
#
# 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: testi18ndirectives.py,v 1.1.2.1 2002/12/23 19:31:37 jim Exp $
"""
import unittest
import os
from cStringIO import StringIO
from zope.configuration.xmlconfig import xmlconfig, Context, XMLConfig
from zope.configuration.exceptions import ConfigurationError
from zope.component.tests.placelesssetup import PlacelessSetup
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():
loader=unittest.TestLoader()
return loader.loadTestsFromTestCase(DirectivesTest)
if __name__=='__main__':
unittest.TextTestRunner().run(test_suite())