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


Python DummyRequest.response方法代码示例

本文整理汇总了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')
开发者ID:C3S,项目名称:c3sMembership,代码行数:30,代码来源:test_writing.py

示例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)
开发者ID:C3S,项目名称:c3sMembership,代码行数:38,代码来源:test_writing.py


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