本文整理汇总了Python中pyramid.testing.DummyRequest.environ方法的典型用法代码示例。如果您正苦于以下问题:Python DummyRequest.environ方法的具体用法?Python DummyRequest.environ怎么用?Python DummyRequest.environ使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyramid.testing.DummyRequest
的用法示例。
在下文中一共展示了DummyRequest.environ方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_build_url_forward_headers
# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import environ [as 别名]
def test_build_url_forward_headers(self):
request = DummyRequest()
request.environ = {
"SERVER_NAME": "example.com"
}
request.registry.settings = {
"checker": {
"forward_headers": ["Cookie"]
}
}
request.headers["Cookie"] = "test"
self.assertEqual(
build_url(
"Test",
"https://camptocamp.com/toto?titi#tutu",
request
),
(
"https://camptocamp.com/toto?titi#tutu",
{
"Cache-Control": "no-cache",
"Cookie": "test",
}
)
)
示例2: get_session_id
# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import environ [as 别名]
def get_session_id(self, cookie_name, cookie_value):
# create dummy request
request = DummyRequest()
request.environ = {'HTTP_HOST': 'localhost'}
request.cookies[cookie_name] = cookie_value
# create authentication policy
setting_prefix = 'auth.policy.'
options = dict((key[len(setting_prefix):], TestPdfSession.settings[key]) for key in TestPdfSession.settings if key.startswith(setting_prefix))
policy = EdAuthAuthenticationPolicy(**options)
# get session id
session_id = policy.unauthenticated_userid(request)
return session_id
示例3: _create_dummy_request
# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import environ [as 别名]
def _create_dummy_request():
request = DummyRequest()
request.environ = {"SERVER_NAME": "example.com"}
return request