Back to index

plone3  3.1.7
test_countries.py
Go to the documentation of this file.
00001 # -*- coding: UTF-8 -*-
00002 """
00003     Country tests.
00004 """
00005 
00006 import unittest
00007 
00008 import plone.i18n.locales
00009 from plone.i18n.locales.interfaces import ICountryAvailability
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 testAvailableCountries():
00026     """
00027       >>> util = queryUtility(ICountryAvailability)
00028       >>> util
00029       <plone.i18n.locales.countries.CountryAvailability object at ...>
00030 
00031       >>> countrycodes = util.getAvailableCountries()
00032       >>> len(countrycodes)
00033       243
00034 
00035       >>> u'de' in countrycodes
00036       True
00037 
00038       >>> countries = util.getCountries()
00039       >>> len(countries)
00040       243
00041 
00042       >>> de = countries[u'de']
00043       >>> de[u'name']
00044       u'Germany'
00045 
00046       >>> de[u'flag']
00047       u'/++resource++country-flags/de.gif'
00048 
00049       >>> countries = util.getCountryListing()
00050       >>> len(countries)
00051       243
00052 
00053       >>> (u'de', u'Germany') in countries
00054       True
00055     """
00056 
00057 def test_suite():
00058     return unittest.TestSuite((
00059         DocTestSuite('plone.i18n.locales.countries'),
00060         DocTestSuite(setUp=configurationSetUp,
00061                      tearDown=tearDown,
00062                      optionflags=doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE),
00063         ))
00064 
00065 if __name__ == '__main__':
00066     unittest.main(defaultTest="test_suite")