本文整理匯總了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)