本文整理汇总了Python中atramhasis.views.views.AtramhasisView.set_locale_cookie方法的典型用法代码示例。如果您正苦于以下问题:Python AtramhasisView.set_locale_cookie方法的具体用法?Python AtramhasisView.set_locale_cookie怎么用?Python AtramhasisView.set_locale_cookie使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类atramhasis.views.views.AtramhasisView
的用法示例。
在下文中一共展示了AtramhasisView.set_locale_cookie方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_default_locale
# 需要导入模块: from atramhasis.views.views import AtramhasisView [as 别名]
# 或者: from atramhasis.views.views.AtramhasisView import set_locale_cookie [as 别名]
def test_default_locale(self):
config_default_lang = settings.get('pyramid.default_locale_name')
self.request.referer = None
self.request.skos_registry = self.regis
atramhasisview = AtramhasisView(self.request)
res = atramhasisview.set_locale_cookie()
self.assertTrue((res.headers.get('Set-Cookie')).startswith('_LOCALE_=' + config_default_lang))
示例2: test_locale_uppercase
# 需要导入模块: from atramhasis.views.views import AtramhasisView [as 别名]
# 或者: from atramhasis.views.views.AtramhasisView import set_locale_cookie [as 别名]
def test_locale_uppercase(self):
testlang = 'it'
self.request.GET['language'] = testlang.upper()
self.request.referer = None
self.request.skos_registry = self.regis
atramhasisview = AtramhasisView(self.request)
res = atramhasisview.set_locale_cookie()
self.assertTrue((res.headers.get('Set-Cookie')).startswith('_LOCALE_=' + testlang))
示例3: test_unsupported_lang
# 需要导入模块: from atramhasis.views.views import AtramhasisView [as 别名]
# 或者: from atramhasis.views.views.AtramhasisView import set_locale_cookie [as 别名]
def test_unsupported_lang(self):
config_default_lang = settings.get('pyramid.default_locale_name')
request = testing.DummyRequest()
request.GET['language'] = 'XX'
request.referer = None
request.skos_registry = self.regis
atramhasisview = AtramhasisView(request)
res = atramhasisview.set_locale_cookie()
self.assertTrue((res.headers.get('Set-Cookie')).startswith('_LOCALE_=' + config_default_lang))
示例4: test_referer
# 需要导入模块: from atramhasis.views.views import AtramhasisView [as 别名]
# 或者: from atramhasis.views.views.AtramhasisView import set_locale_cookie [as 别名]
def test_referer(self):
testlang = 'it'
testurl = 'http://www.foo.bar'
self.request.GET['language'] = testlang.upper()
self.request.referer = testurl
self.request.skos_registry = self.regis
atramhasisview = AtramhasisView(self.request)
res = atramhasisview.set_locale_cookie()
self.assertEqual(res.status, '302 Found')
self.assertEqual(res.location, testurl)