本文整理汇总了Python中pyramid.testing.DummyRequest.get_response方法的典型用法代码示例。如果您正苦于以下问题:Python DummyRequest.get_response方法的具体用法?Python DummyRequest.get_response怎么用?Python DummyRequest.get_response使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyramid.testing.DummyRequest
的用法示例。
在下文中一共展示了DummyRequest.get_response方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_websocket_good_origin
# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import get_response [as 别名]
def test_websocket_good_origin(config):
config.registry.settings.update({'origins': 'http://good'})
config.include('h.streamer')
req = DummyRequest(headers={'Origin': 'http://good'})
req.get_response = MagicMock()
res = websocket(req)
assert res.code != 403
示例2: test_websocket_same_origin
# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import get_response [as 别名]
def test_websocket_same_origin(config):
config.include('h.streamer')
# example.com is the dummy request default host URL
req = DummyRequest(headers={'Origin': 'http://example.com'})
req.get_response = MagicMock()
res = websocket(req)
assert res.code != 403
示例3: test_websocket_view_same_origin
# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import get_response [as 别名]
def test_websocket_view_same_origin(config):
# example.com is the dummy request default host URL
config.registry.settings.update({'origins': []})
req = DummyRequest(headers={'Origin': 'http://example.com'})
req.get_response = lambda _: mock.sentinel.good_response
res = views.websocket_view(req)
assert res == mock.sentinel.good_response
示例4: test_get_collection_view_with_size
# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import get_response [as 别名]
def test_get_collection_view_with_size(self):
coll = get_root_collection(IFoo)
app_url = self._get_app_url()
path_url = 'http://0.0.0.0:6543/foos/'
req = DummyRequest(application_url=app_url, host_url=app_url,
path_url=path_url,
url=path_url + '?size=10',
params=dict(size=10),
registry=self.config.registry,
accept=['*/*'])
req.get_response = lambda exc: None
view = GetCollectionView(coll, req)
res = view()
self.assert_is_not_none(res)
self.assert_equal(view.context.slice.start, 0)
self.assert_equal(view.context.slice.stop, 10)
# Try again with size exceeding the allowed maximum limit (page size).
req.params = dict(size=10000)
req.url = path_url + '?size=10000'
res = view()
self.assert_is_not_none(res)
self.assert_equal(view.context.slice.start, 0)
self.assert_equal(view.context.slice.stop, FooCollection.max_limit)
示例5: test_get_collection_view_with_size
# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import get_response [as 别名]
def test_get_collection_view_with_size(self, class_ini, app_creator):
coll = get_root_collection(IFoo)
path_url = 'http://0.0.0.0:6543/foos/'
req = DummyRequest(application_url=class_ini.app_url,
host_url=class_ini.app_url,
path_url=path_url,
url=path_url + '?size=10',
params=dict(size=10),
registry=app_creator.config.registry,
accept=['*/*'])
req.get_response = lambda exc: None
view = GetCollectionView(coll, req)
res = view()
assert res is not None
assert view.context.slice.start == 0
assert view.context.slice.stop == 10
# Try again with size exceeding the allowed maximum limit (page size).
req.params = dict(size=10000)
req.url = path_url + '?size=10000'
res = view()
assert res is not None
assert view.context.slice.start == 0
assert view.context.slice.stop == FooCollection.max_limit
示例6: test_websocket_view_good_origin
# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import get_response [as 别名]
def test_websocket_view_good_origin(config):
config.registry.settings.update({'origins': ['http://good']})
req = DummyRequest(headers={'Origin': 'http://good'})
req.get_response = lambda _: mock.sentinel.good_response
res = views.websocket_view(req)
assert res == mock.sentinel.good_response