当前位置: 首页>>代码示例>>Python>>正文


Python DummyRequest.get_response方法代码示例

本文整理汇总了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
开发者ID:coolcool21,项目名称:h,代码行数:9,代码来源:streamer_test.py

示例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
开发者ID:coolcool21,项目名称:h,代码行数:9,代码来源:streamer_test.py

示例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
开发者ID:Cinemacloud,项目名称:h,代码行数:9,代码来源:views_test.py

示例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)
开发者ID:b8va,项目名称:everest,代码行数:25,代码来源:test_views.py

示例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
开发者ID:helixyte,项目名称:everest,代码行数:25,代码来源:test_views.py

示例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
开发者ID:Cinemacloud,项目名称:h,代码行数:8,代码来源:views_test.py


注:本文中的pyramid.testing.DummyRequest.get_response方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。