Back to index

plone3  3.1.7
Functions
plone.i18n.normalizer.tests.test_adapters Namespace Reference

Functions

def configurationSetUp
def testUserPreferredFileNameNormalizer
def testUserPreferredURLNormalizer
def test_suite

Function Documentation

Definition at line 20 of file test_adapters.py.

00020 
00021 def configurationSetUp(self):
00022     import plone.i18n.normalizer
00023     import zope.component
00024     setUp()
00025     XMLConfig('meta.zcml', zope.component)()
00026     XMLConfig('configure.zcml', plone.i18n.normalizer)()
00027     zope.component.provideAdapter(BrowserLanguages)
00028 

Here is the call graph for this function:

Definition at line 85 of file test_adapters.py.

00085 
00086 def test_suite():
00087     return unittest.TestSuite((
00088         DocTestSuite(setUp=configurationSetUp,
00089                      tearDown=tearDown,
00090                      optionflags=doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE),
00091         ))

Create a German and English request and filename normalizer:

  >>> de_request = TestRequest(environ=dict(HTTP_ACCEPT_LANGUAGE = 'de'))
  >>> de_filename = UserPreferredFileNameNormalizer(de_request)

  >>> en_request = TestRequest(environ=dict(HTTP_ACCEPT_LANGUAGE = 'en'))
  >>> en_filename = UserPreferredFileNameNormalizer(en_request)

Test the German normalization:

  >>> de_filename.normalize(u'simpleandsafe')
  'simpleandsafe'

  >>> de_filename.normalize(unicode('text with umläut', 'utf-8'))
  'text with umlaeut'

Test the English normalization:

  >>> en_filename.normalize(u'simpleandsafe')
  'simpleandsafe'

  >>> en_filename.normalize(unicode('text with umläut', 'utf-8'))
  'text with umlaeut'

Definition at line 29 of file test_adapters.py.

00029 
00030 def testUserPreferredFileNameNormalizer():
00031     """
00032     Create a German and English request and filename normalizer:
00033 
00034       >>> de_request = TestRequest(environ=dict(HTTP_ACCEPT_LANGUAGE = 'de'))
00035       >>> de_filename = UserPreferredFileNameNormalizer(de_request)
00036 
00037       >>> en_request = TestRequest(environ=dict(HTTP_ACCEPT_LANGUAGE = 'en'))
00038       >>> en_filename = UserPreferredFileNameNormalizer(en_request)
00039 
00040     Test the German normalization:
00041 
00042       >>> de_filename.normalize(u'simpleandsafe')
00043       'simpleandsafe'
00044 
00045       >>> de_filename.normalize(unicode('text with umläut', 'utf-8'))
00046       'text with umlaeut'
00047 
00048     Test the English normalization:
00049 
00050       >>> en_filename.normalize(u'simpleandsafe')
00051       'simpleandsafe'
00052 
00053       >>> en_filename.normalize(unicode('text with umläut', 'utf-8'))
00054       'text with umlaeut'
00055     """
00056 

Create a German and English request and url normalizer:

  >>> de_request = TestRequest(environ=dict(HTTP_ACCEPT_LANGUAGE = 'de'))
  >>> de_url = UserPreferredURLNormalizer(de_request)

  >>> en_request = TestRequest(environ=dict(HTTP_ACCEPT_LANGUAGE = 'en'))
  >>> en_url = UserPreferredURLNormalizer(en_request)

Test the German normalization:

  >>> de_url.normalize(u'simpleandsafe')
  'simpleandsafe'

  >>> de_url.normalize(unicode('text with umläut', 'utf-8'))
  'text-with-umlaeut'

Test the English normalization:

  >>> en_url.normalize(u'simpleandsafe')
  'simpleandsafe'

  >>> en_url.normalize(unicode('text with umläut', 'utf-8'))
  'text-with-umlaeut'

Definition at line 57 of file test_adapters.py.

00057 
00058 def testUserPreferredURLNormalizer():
00059     """
00060     Create a German and English request and url normalizer:
00061 
00062       >>> de_request = TestRequest(environ=dict(HTTP_ACCEPT_LANGUAGE = 'de'))
00063       >>> de_url = UserPreferredURLNormalizer(de_request)
00064 
00065       >>> en_request = TestRequest(environ=dict(HTTP_ACCEPT_LANGUAGE = 'en'))
00066       >>> en_url = UserPreferredURLNormalizer(en_request)
00067 
00068     Test the German normalization:
00069 
00070       >>> de_url.normalize(u'simpleandsafe')
00071       'simpleandsafe'
00072 
00073       >>> de_url.normalize(unicode('text with umläut', 'utf-8'))
00074       'text-with-umlaeut'
00075 
00076     Test the English normalization:
00077 
00078       >>> en_url.normalize(u'simpleandsafe')
00079       'simpleandsafe'
00080 
00081       >>> en_url.normalize(unicode('text with umläut', 'utf-8'))
00082       'text-with-umlaeut'
00083     """
00084