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


Python DummyRequest.method方法代码示例

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


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

示例1: test_invalidMethod

# 需要导入模块: from twisted.web.test.test_web import DummyRequest [as 别名]
# 或者: from twisted.web.test.test_web.DummyRequest import method [as 别名]
 def test_invalidMethod(self):
     """
     L{UserDirectory.render} raises L{UnsupportedMethod} in response to a
     non-I{GET} request.
     """
     request = DummyRequest([""])
     request.method = "POST"
     self.assertRaises(server.UnsupportedMethod, self.directory.render, request)
开发者ID:RockySteveJobs,项目名称:python-for-android,代码行数:10,代码来源:test_distrib.py

示例2: do_request

# 需要导入模块: from twisted.web.test.test_web import DummyRequest [as 别名]
# 或者: from twisted.web.test.test_web.DummyRequest import method [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
开发者ID:warner,项目名称:petmail,代码行数:10,代码来源:test_server.py

示例3: create_request

# 需要导入模块: from twisted.web.test.test_web import DummyRequest [as 别名]
# 或者: from twisted.web.test.test_web.DummyRequest import method [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
开发者ID:AndrewCvekl,项目名称:vumi,代码行数:10,代码来源:test_vas2nets_stubs.py

示例4: request_generator

# 需要导入模块: from twisted.web.test.test_web import DummyRequest [as 别名]
# 或者: from twisted.web.test.test_web.DummyRequest import method [as 别名]
def request_generator(url, method='GET', content=True, headers=True):
    request = DummyRequest(url)
    request.method = method
    if content:
        request.content = StringIO()
    if headers:
        request.requestHeaders = Headers()

    return request
开发者ID:DamnWidget,项目名称:mamba,代码行数:11,代码来源:test_web.py

示例5: makeRequest

# 需要导入模块: from twisted.web.test.test_web import DummyRequest [as 别名]
# 或者: from twisted.web.test.test_web.DummyRequest import method [as 别名]
 def makeRequest(self, method='GET', clientAddress=None):
     """
     Create a L{DummyRequest} (change me to create a
     L{twisted.web.http.Request} instead).
     """
     request = DummyRequest('/')
     request.method = method
     request.client = clientAddress
     return request
开发者ID:jxta,项目名称:cc,代码行数:11,代码来源:test_httpauth.py

示例6: make_request

# 需要导入模块: from twisted.web.test.test_web import DummyRequest [as 别名]
# 或者: from twisted.web.test.test_web.DummyRequest import method [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
开发者ID:shyba,项目名称:cryptosync,代码行数:11,代码来源:test_webserver.py

示例7: test_renderHEAD

# 需要导入模块: from twisted.web.test.test_web import DummyRequest [as 别名]
# 或者: from twisted.web.test.test_web.DummyRequest import method [as 别名]
 def test_renderHEAD(self):
     """
     The rendering behavior of L{UnauthorizedResource} for a I{HEAD} request
     is like its handling of a I{GET} request, but no response body is
     written.
     """
     request = DummyRequest([''])
     request.method = 'HEAD'
     self._unauthorizedRenderTest(request)
     self.assertEqual('', ''.join(request.written))
开发者ID:0004c,项目名称:VTK,代码行数:12,代码来源:test_httpauth.py

示例8: test_renderPOST

# 需要导入模块: from twisted.web.test.test_web import DummyRequest [as 别名]
# 或者: from twisted.web.test.test_web.DummyRequest import method [as 别名]
 def test_renderPOST(self):
     """
     If the method is not C{GET}, L{WebSocketsResource} returns a failed
     request.
     """
     request = DummyRequest("/")
     request.method = "POST"
     request.headers.update({
         "upgrade": "Websocket",
         "connection": "Upgrade",
         "sec-websocket-key": "secure",
         "sec-websocket-version": "13"})
     self.assertRequestFail(request)
开发者ID:codecats,项目名称:kitty,代码行数:15,代码来源:test_websockets.py

示例9: test_withRequest

# 需要导入模块: from twisted.web.test.test_web import DummyRequest [as 别名]
# 或者: from twisted.web.test.test_web.DummyRequest import method [as 别名]
 def test_withRequest(self):
     """
     When an XML-RPC method is called and the implementation is
     decorated with L{withRequest}, the request object is passed as
     the first argument.
     """
     request = DummyRequest('/RPC2')
     request.method = "POST"
     request.content = StringIO(xmlrpclib.dumps(("foo",), 'withRequest'))
     def valid(n, request):
         data = xmlrpclib.loads(request.written[0])
         self.assertEqual(data, (('POST foo',), None))
     d = request.notifyFinish().addCallback(valid, request)
     self.resource.render_POST(request)
     return d
开发者ID:12019,项目名称:OpenWrt_Luci_Lua,代码行数:17,代码来源:test_xmlrpc.py

示例10: create_request

# 需要导入模块: from twisted.web.test.test_web import DummyRequest [as 别名]
# 或者: from twisted.web.test.test_web.DummyRequest import method [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
开发者ID:dmaclay,项目名称:vumi,代码行数:22,代码来源:test_vas2nets.py


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