本文整理汇总了Python中pyramid.testing.DummyRequest.response方法的典型用法代码示例。如果您正苦于以下问题:Python DummyRequest.response方法的具体用法?Python DummyRequest.response怎么用?Python DummyRequest.response使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyramid.testing.DummyRequest
的用法示例。
在下文中一共展示了DummyRequest.response方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_call
# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import response [as 别名]
def test_call(self):
writer = DefaultPaginationRequestWriter(
PropertyNamingMock(
'cookie_prefix.page_number',
'cookie_prefix.page_size',
'cookie_prefix.sort_property',
'cookie_prefix.sort_direction'
)
)
request = DummyRequest()
request.response = ResponseMock()
pagination_request = PaginationRequest(
PagingRequest(3, 24),
Sorting('some_sort_property', 'desc'))
writer(request, pagination_request)
self.assertEqual(
request.response.get_cookie('cookie_prefix.page_number'),
'3')
self.assertEqual(
request.response.get_cookie('cookie_prefix.page_size'),
'24')
self.assertEqual(
request.response.get_cookie('cookie_prefix.sort_property'),
'some_sort_property')
self.assertEqual(
request.response.get_cookie('cookie_prefix.sort_direction'),
'desc')
示例2: test_write
# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import response [as 别名]
def test_write(self):
request = DummyRequest()
response_mock = ResponseMock()
request.response = response_mock
sorting = Sorting('id', 'desc')
sorting_writer = CookieSortingWriter(
request,
PropertyNamingMock(
'page_number',
'page_size',
'sort_property',
'sort_direction'
)
)
sorting_writer(sorting)
self.assertEqual(response_mock.get_cookie('sort_property'), 'id')
self.assertEqual(response_mock.get_cookie('sort_direction'), 'desc')
self.assertEqual(response_mock.call_count(), 2)
request = DummyRequest()
response_mock = ResponseMock()
request.response = response_mock
sorting = Sorting('id', 'desc')
sorting_writer = CookieSortingWriter(
request,
PropertyNamingMock(
'cookie_prefix.page_number',
'cookie_prefix.page_size',
'cookie_prefix.sort_property',
'cookie_prefix.sort_direction'
)
)
sorting_writer(sorting)
self.assertEqual(response_mock.get_cookie('cookie_prefix.sort_property'), 'id')
self.assertEqual(response_mock.get_cookie('cookie_prefix.sort_direction'), 'desc')
self.assertEqual(response_mock.call_count(), 2)