Back to index

plone3  3.1.7
test_cctlds.py
Go to the documentation of this file.
00001 # -*- coding: UTF-8 -*-
00002 """
00003     ccTLD tests.
00004 """
00005 
00006 import unittest
00007 
00008 import plone.i18n.locales
00009 from plone.i18n.locales.interfaces import ICcTLDInformation
00010 
00011 import zope.app.publisher.browser
00012 import zope.component
00013 from zope.component import queryUtility
00014 from zope.component.testing import setUp, tearDown
00015 from zope.configuration.xmlconfig import XMLConfig
00016 from zope.testing import doctest
00017 from zope.testing.doctestunit import DocTestSuite
00018 
00019 def configurationSetUp(self):
00020     setUp()
00021     XMLConfig('meta.zcml', zope.component)()
00022     XMLConfig('meta.zcml', zope.app.publisher.browser)()
00023     XMLConfig('configure.zcml', plone.i18n.locales)()
00024 
00025 def testccTLDs():
00026     """
00027       >>> util = queryUtility(ICcTLDInformation)
00028       >>> util
00029       <plone.i18n.locales.cctld.CcTLDInformation object at ...>
00030 
00031       >>> tlds = util.getAvailableTLDs()
00032       >>> len(tlds)
00033       266
00034 
00035       >>> u'nl' in tlds
00036       True
00037 
00038       >>> tlds = util.getTLDs()
00039       >>> len(tlds)
00040       266
00041 
00042       >>> util.getLanguagesForTLD(u'nl')
00043       [u'nl']
00044 
00045       >>> util.getLanguagesForTLD(u'be')
00046       [u'nl', u'fr']
00047     """
00048 
00049 def test_suite():
00050     return unittest.TestSuite((
00051         DocTestSuite('plone.i18n.locales.cctld'),
00052         DocTestSuite(setUp=configurationSetUp,
00053                      tearDown=tearDown,
00054                      optionflags=doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE),
00055         ))
00056 
00057 if __name__ == '__main__':
00058     unittest.main(defaultTest="test_suite")