Back to index

plone3  3.1.7
Classes | Functions
plone.i18n.negotiator.tests.test_subdomain Namespace Reference

Classes

class  TestRequest

Functions

def configurationSetUp
def testSubdomainNegotiator
def test_suite

Function Documentation

Definition at line 22 of file test_subdomain.py.

00022 
00023 def configurationSetUp(self):
00024     setUp()
00025     XMLConfig('meta.zcml', zope.component)()
00026 

Here is the call graph for this function:

Definition at line 72 of file test_subdomain.py.

00072 
00073 def test_suite():
00074     return unittest.TestSuite((
00075         DocTestSuite(setUp=configurationSetUp,
00076                      tearDown=tearDown,
00077                      optionflags=doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE),
00078         ))

  >>> from plone.i18n.negotiator.negotiator import Negotiator
  >>> negotiator = Negotiator()
  >>> from plone.i18n.negotiator.subdomain import SubdomainLanguage
  >>> negotiator[0] = SubdomainLanguage

  >>> from plone.i18n.locales.interfaces import ICcTLDInformation
  >>> from plone.i18n.locales.interfaces import ILanguageAvailability
  >>> from plone.i18n.locales.cctld import CcTLDInformation
  >>> from plone.i18n.locales.languages import LanguageAvailability

  >>> request = TestRequest('de.plone.org')
  >>> negotiator.getLanguage(('de', ), request) is None
  True

  >>> from zope.component import getSiteManager
  >>> lang_avail = LanguageAvailability()
  >>> cctld = CcTLDInformation()

  >>> sm = getSiteManager()
  >>> sm.registerUtility(lang_avail, ILanguageAvailability)
  >>> sm.registerUtility(cctld, ICcTLDInformation)

  >>> data = [
  ...    (('de', 'en'), None),
  ...    (('de', 'en'), ''),
  ...    (('de', 'en'), 'www.plone.org'),
  ...    (('de', 'en'), 'de.plone.org'),
  ...    (('fi', 'en'), 'fi.plone.org'),
  ...    (('pt', 'en'), 'pt.plone.org:8081'),
  ... ]

  >>> for langs, host in data:
  ...    request = TestRequest(host)
  ...    print negotiator.getLanguage(langs, request)
  None
  None
  None
  de
  fi
  pt

Definition at line 27 of file test_subdomain.py.

00027 
00028 def testSubdomainNegotiator():
00029     """
00030       >>> from plone.i18n.negotiator.negotiator import Negotiator
00031       >>> negotiator = Negotiator()
00032       >>> from plone.i18n.negotiator.subdomain import SubdomainLanguage
00033       >>> negotiator[0] = SubdomainLanguage
00034 
00035       >>> from plone.i18n.locales.interfaces import ICcTLDInformation
00036       >>> from plone.i18n.locales.interfaces import ILanguageAvailability
00037       >>> from plone.i18n.locales.cctld import CcTLDInformation
00038       >>> from plone.i18n.locales.languages import LanguageAvailability
00039 
00040       >>> request = TestRequest('de.plone.org')
00041       >>> negotiator.getLanguage(('de', ), request) is None
00042       True
00043 
00044       >>> from zope.component import getSiteManager
00045       >>> lang_avail = LanguageAvailability()
00046       >>> cctld = CcTLDInformation()
00047 
00048       >>> sm = getSiteManager()
00049       >>> sm.registerUtility(lang_avail, ILanguageAvailability)
00050       >>> sm.registerUtility(cctld, ICcTLDInformation)
00051 
00052       >>> data = [
00053       ...    (('de', 'en'), None),
00054       ...    (('de', 'en'), ''),
00055       ...    (('de', 'en'), 'www.plone.org'),
00056       ...    (('de', 'en'), 'de.plone.org'),
00057       ...    (('fi', 'en'), 'fi.plone.org'),
00058       ...    (('pt', 'en'), 'pt.plone.org:8081'),
00059       ... ]
00060 
00061       >>> for langs, host in data:
00062       ...    request = TestRequest(host)
00063       ...    print negotiator.getLanguage(langs, request)
00064       None
00065       None
00066       None
00067       de
00068       fi
00069       pt
00070     """
00071