cubicweb/web/test/unittest_request.py
changeset 12567 26744ad37953
parent 11913 4516c3956d46
equal deleted inserted replaced
12566:6b3523f81f42 12567:26744ad37953
     1 """misc. unittests for utility functions
     1 """misc. unittests for utility functions
     2 """
     2 """
     3 
     3 
     4 import unittest
     4 import unittest
     5 from functools import partial
     5 from functools import partial
     6 
       
     7 from six import text_type
       
     8 
     6 
     9 from cubicweb.devtools.fake import FakeConfig, FakeCWRegistryStore
     7 from cubicweb.devtools.fake import FakeConfig, FakeCWRegistryStore
    10 
     8 
    11 from cubicweb.web.request import (CubicWebRequestBase, _parse_accept_header,
     9 from cubicweb.web.request import (CubicWebRequestBase, _parse_accept_header,
    12                                   _mimetype_sort_key, _mimetype_parser, _charset_sort_key)
    10                                   _mimetype_sort_key, _mimetype_parser, _charset_sort_key)
    82 
    80 
    83     def test_build_url_language_from_url(self):
    81     def test_build_url_language_from_url(self):
    84         vreg = FakeCWRegistryStore(FakeConfig(), initlog=False)
    82         vreg = FakeCWRegistryStore(FakeConfig(), initlog=False)
    85         vreg.config['base-url'] = 'http://testing.fr/cubicweb/'
    83         vreg.config['base-url'] = 'http://testing.fr/cubicweb/'
    86         vreg.config['language-mode'] = 'url-prefix'
    84         vreg.config['language-mode'] = 'url-prefix'
    87         vreg.config.translations['fr'] = text_type, text_type
    85         vreg.config.translations['fr'] = str, str
    88         req = CubicWebRequestBase(vreg)
    86         req = CubicWebRequestBase(vreg)
    89         # Override from_controller to avoid getting into relative_path method,
    87         # Override from_controller to avoid getting into relative_path method,
    90         # which is not implemented in CubicWebRequestBase.
    88         # which is not implemented in CubicWebRequestBase.
    91         req.from_controller = lambda : 'not view'
    89         req.from_controller = lambda : 'not view'
    92         self.assertEqual(req.lang, 'en')  # site's default language
    90         self.assertEqual(req.lang, 'en')  # site's default language