Back to index

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

Classes

class  TestRequest

Functions

def configurationSetUp
def testPathNegotiator
def test_suite

Function Documentation

Definition at line 22 of file test_path.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 58 of file test_path.py.

00058 
00059 def test_suite():
00060     return unittest.TestSuite((
00061         DocTestSuite(setUp=configurationSetUp,
00062                      tearDown=tearDown,
00063                      optionflags=doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE),
00064         ))

  >>> from plone.i18n.negotiator.negotiator import Negotiator
  >>> negotiator = Negotiator()
  >>> from plone.i18n.negotiator.path import PathLanguage
  >>> negotiator[0] = PathLanguage

  >>> from plone.i18n.locales.interfaces import ILanguageAvailability
  >>> from plone.i18n.locales.languages import LanguageAvailability

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

  >>> sm = getSiteManager()
  >>> sm.registerUtility(lang_avail, provided=ILanguageAvailability)

  >>> data = [
  ...    (('de', 'en'),  ['portal', 'de', 'folder', 'object']),
  ...    (('en', 'fi'), ['portal', 'en-us', 'fi', 'folder', 'object']),
  ...    (('ca', 'pt'), ['portal', 'ca', 'folder', 'object']),
  ... ]

  >>> for langs, path in data:
  ...    request = TestRequest(path)
  ...    negotiator.getLanguage(langs, request)
  'de'
  'fi'
  'ca'

Definition at line 27 of file test_path.py.

00027 
00028 def testPathNegotiator():
00029     """
00030       >>> from plone.i18n.negotiator.negotiator import Negotiator
00031       >>> negotiator = Negotiator()
00032       >>> from plone.i18n.negotiator.path import PathLanguage
00033       >>> negotiator[0] = PathLanguage
00034 
00035       >>> from plone.i18n.locales.interfaces import ILanguageAvailability
00036       >>> from plone.i18n.locales.languages import LanguageAvailability
00037 
00038       >>> from zope.component import getSiteManager
00039       >>> lang_avail = LanguageAvailability()
00040 
00041       >>> sm = getSiteManager()
00042       >>> sm.registerUtility(lang_avail, provided=ILanguageAvailability)
00043 
00044       >>> data = [
00045       ...    (('de', 'en'),  ['portal', 'de', 'folder', 'object']),
00046       ...    (('en', 'fi'), ['portal', 'en-us', 'fi', 'folder', 'object']),
00047       ...    (('ca', 'pt'), ['portal', 'ca', 'folder', 'object']),
00048       ... ]
00049 
00050       >>> for langs, path in data:
00051       ...    request = TestRequest(path)
00052       ...    negotiator.getLanguage(langs, request)
00053       'de'
00054       'fi'
00055       'ca'
00056     """
00057