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


Python DummyRequest.getCookie方法代码示例

本文整理汇总了Python中twisted.web.test.requesthelper.DummyRequest.getCookie方法的典型用法代码示例。如果您正苦于以下问题:Python DummyRequest.getCookie方法的具体用法?Python DummyRequest.getCookie怎么用?Python DummyRequest.getCookie使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twisted.web.test.requesthelper.DummyRequest的用法示例。


在下文中一共展示了DummyRequest.getCookie方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_should_authorize_child_resource_non_ajax_GET_requests

# 需要导入模块: from twisted.web.test.requesthelper import DummyRequest [as 别名]
# 或者: from twisted.web.test.requesthelper.DummyRequest import getCookie [as 别名]
    def test_should_authorize_child_resource_non_ajax_GET_requests(self):
        request = DummyRequest(['features'])

        request.getCookie = MagicMock(return_value='irrelevant -- stubbed')
        self.root_resource._child_resources.add('features', FeaturesResource())

        d = self.web.get(request)

        def assert_unauthorized(_):
            self.assertEqual(200, request.code)

        d.addCallback(assert_unauthorized)
        return d
开发者ID:codergolem,项目名称:pixelated-user-agent,代码行数:15,代码来源:test_root_resource.py

示例2: test_should_unavailable_child_resource_during_startup

# 需要导入模块: from twisted.web.test.requesthelper import DummyRequest [as 别名]
# 或者: from twisted.web.test.requesthelper.DummyRequest import getCookie [as 别名]
    def test_should_unavailable_child_resource_during_startup(self):
        self.root_resource._mode = MODE_STARTUP

        request = DummyRequest(['/child'])
        request.getCookie = MagicMock(return_value='irrelevant -- stubbed')

        d = self.web.get(request)

        def assert_unavailable(_):
            self.assertEqual(503, request.responseCode)
            self.assertEqual("Service Unavailable", request.written[0])

        d.addCallback(assert_unavailable)
        return d
开发者ID:pixelated,项目名称:pixelated-user-agent,代码行数:16,代码来源:test_root_resource.py

示例3: test_should_unauthorize_child_resource_ajax_requests_when_csrf_mismatch

# 需要导入模块: from twisted.web.test.requesthelper import DummyRequest [as 别名]
# 或者: from twisted.web.test.requesthelper.DummyRequest import getCookie [as 别名]
    def test_should_unauthorize_child_resource_ajax_requests_when_csrf_mismatch(self):
        request = DummyRequest(['/child'])
        self._mock_ajax_csrf(request, 'stubbed csrf token')

        request.getCookie = MagicMock(return_value='mismatched csrf token')

        d = self.web.get(request)

        def assert_unauthorized(_):
            self.assertEqual(401, request.responseCode)
            self.assertEqual("Unauthorized!", request.written[0])

        d.addCallback(assert_unauthorized)
        return d
开发者ID:Meistache,项目名称:pixelated-user-agent,代码行数:16,代码来源:test_root_resource.py

示例4: test_should_404_non_existing_resource_with_valid_csrf

# 需要导入模块: from twisted.web.test.requesthelper import DummyRequest [as 别名]
# 或者: from twisted.web.test.requesthelper.DummyRequest import getCookie [as 别名]
    def test_should_404_non_existing_resource_with_valid_csrf(self):
        request = DummyRequest(['/non-existing-child'])
        request.method = 'POST'
        self._mock_ajax_csrf(request, 'stubbed csrf token')

        request.getCookie = MagicMock(return_value='stubbed csrf token')

        d = self.web.get(request)

        def assert_not_found(_):
            self.assertEqual(404, request.responseCode)
            self.assertIn("No Such Resource", request.written[0])

        d.addCallback(assert_not_found)
        return d
开发者ID:pixelated,项目名称:pixelated-user-agent,代码行数:17,代码来源:test_root_resource.py

示例5: test_should_unauthorize_child_resource_non_ajax_POST_requests_when_csrf_input_mismatch

# 需要导入模块: from twisted.web.test.requesthelper import DummyRequest [as 别名]
# 或者: from twisted.web.test.requesthelper.DummyRequest import getCookie [as 别名]
    def test_should_unauthorize_child_resource_non_ajax_POST_requests_when_csrf_input_mismatch(self):
        request = DummyRequest(['mails'])
        request.method = 'POST'
        request.addArg('csrftoken', 'some csrf token')
        mock_content = MagicMock()
        mock_content.read = MagicMock(return_value={})
        request.content = mock_content

        request.getCookie = MagicMock(return_value='mismatched csrf token')

        d = self.web.get(request)

        def assert_unauthorized(_):
            self.assertEqual(401, request.responseCode)
            self.assertEqual("Unauthorized!", request.written[0])

        d.addCallback(assert_unauthorized)
        return d
开发者ID:pixelated,项目名称:pixelated-user-agent,代码行数:20,代码来源:test_root_resource.py


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