本文整理汇总了Python中twisted.web.test.test_web.DummyRequest.args方法的典型用法代码示例。如果您正苦于以下问题:Python DummyRequest.args方法的具体用法?Python DummyRequest.args怎么用?Python DummyRequest.args使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.web.test.test_web.DummyRequest
的用法示例。
在下文中一共展示了DummyRequest.args方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_request
# 需要导入模块: from twisted.web.test.test_web import DummyRequest [as 别名]
# 或者: from twisted.web.test.test_web.DummyRequest import args [as 别名]
def create_request(params={}, path='/', method='POST'):
"""
Creates a dummy Vas2Nets request for testing our resources with
"""
request = DummyRequest(path)
request.method = method
request.args = params
return request
示例2: do_request
# 需要导入模块: from twisted.web.test.test_web import DummyRequest [as 别名]
# 或者: from twisted.web.test.test_web.DummyRequest import args [as 别名]
def do_request(resource, t=None, method="GET"):
req = DummyRequest([])
req.method = method
req.args = {}
if t:
req.args["t"] = [t]
req.render(resource)
return "".join(req.written), req
示例3: make_request
# 需要导入模块: from twisted.web.test.test_web import DummyRequest [as 别名]
# 或者: from twisted.web.test.test_web.DummyRequest import args [as 别名]
def make_request(uri='', method='GET', args={}):
site = make_site(authenticator=Mock())
request = DummyRequest(uri.split('/'))
request.method = method
request.args = args
resource = site.getResourceFor(request)
request.render(resource)
request.data = "".join(request.written)
return request
示例4: test_download_render_POST
# 需要导入模块: from twisted.web.test.test_web import DummyRequest [as 别名]
# 或者: from twisted.web.test.test_web.DummyRequest import args [as 别名]
def test_download_render_POST(self):
"""Download JSON data file."""
datastore = DataStore()
datastore.add_value("var1", 1, 1)
datastore.add_value("var2", 2, 2)
resource = Index(datastore)
request = DummyRequest(['foo'])
request.args = {'download': 'download'}
d = request.notifyFinish()
result = resource.render_POST(request)
self.assertEqual(result, server.NOT_DONE_YET)
yield d
expected = '["var1", 1, 1]\n["var2", 2, 2]'
self.assertEqual(expected, ''.join(request.written))
示例5: create_request
# 需要导入模块: from twisted.web.test.test_web import DummyRequest [as 别名]
# 或者: from twisted.web.test.test_web.DummyRequest import args [as 别名]
def create_request(self, dictionary={}, path='/', method='POST'):
"""
Creates a dummy Vas2Nets request for testing our resources with
"""
request = DummyRequest(path)
request.method = method
args = {
'messageid': [str(uuid4())],
'time': [self.today.strftime('%Y.%m.%d %H:%M:%S')],
'sender': ['0041791234567'],
'destination': ['9292'],
'provider': ['provider'],
'keyword': [''],
'header': [''],
'text': [''],
'keyword': [''],
}
args.update(dictionary)
request.args = args
return request
示例6: test_upload_render_POST
# 需要导入模块: from twisted.web.test.test_web import DummyRequest [as 别名]
# 或者: from twisted.web.test.test_web.DummyRequest import args [as 别名]
def test_upload_render_POST(self):
"""Upload JSON data file."""
datastore = DataStore()
resource = Index(datastore)
request = DummyRequest(['foo'])
request.args = {'data_file': ['["var1", 1, 1]\n["var2", 2, 2]'],
'upload': 'upload'}
def fake_redirect(path):
request.redirect_to = path
request.redirect = fake_redirect
d = request.notifyFinish()
result = resource.render_POST(request)
self.assertEqual(result, server.NOT_DONE_YET)
yield d
self.assertEqual(request.redirect_to, '/')