本文整理汇总了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
示例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
示例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
示例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
示例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