本文整理汇总了Python中twisted.web.test.requesthelper.DummyChannel.site方法的典型用法代码示例。如果您正苦于以下问题:Python DummyChannel.site方法的具体用法?Python DummyChannel.site怎么用?Python DummyChannel.site使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.web.test.requesthelper.DummyChannel
的用法示例。
在下文中一共展示了DummyChannel.site方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: renderResource
# 需要导入模块: from twisted.web.test.requesthelper import DummyChannel [as 别名]
# 或者: from twisted.web.test.requesthelper.DummyChannel import site [as 别名]
def renderResource(self, resource, path):
s = appserver.NevowSite(resource)
channel = DummyChannel()
channel.site = s
r = appserver.NevowRequest(channel, True)
r.path = path
return r.process()
示例2: create_request
# 需要导入模块: from twisted.web.test.requesthelper import DummyChannel [as 别名]
# 或者: from twisted.web.test.requesthelper.DummyChannel import site [as 别名]
def create_request(self):
channel = DummyChannel()
channel.site = PixelatedSite(MagicMock())
request = PixelatedSite.requestFactory(channel=channel, queued=True)
request.method = "GET"
request.uri = "localhost"
request.clientproto = 'HTTP/1.1'
request.prepath = []
request.postpath = request.uri.split('/')[1:]
request.path = "/"
return request
示例3: getTextOfPage
# 需要导入模块: from twisted.web.test.requesthelper import DummyChannel [as 别名]
# 或者: from twisted.web.test.requesthelper.DummyChannel import site [as 别名]
def getTextOfPage(root, page, args=None, return_request=False):
"""This perpetrates several awful hacks."""
if args is not None:
page += '?' + urllib.urlencode(args)
channel = DummyChannel()
channel.site = Site(root)
r = Request(channel, 0)
r.content = StringIO()
r.requestReceived("GET", "/" + page, "1.1")
if return_request:
return channel.transport.written.getvalue(), r
else:
return channel.transport.written.getvalue()
示例4: test_renderPOST
# 需要导入模块: from twisted.web.test.requesthelper import DummyChannel [as 别名]
# 或者: from twisted.web.test.requesthelper.DummyChannel import site [as 别名]
def test_renderPOST(self):
"""
A POST request with form data has the form data parsed into
C{request.fields}.
"""
class Res(Render):
def renderHTTP(self, ctx):
return b''
s = appserver.NevowSite(Res())
channel = DummyChannel()
channel.site = s
r = appserver.NevowRequest(channel, True)
r.method = b'POST'
r.path = b'/'
r.content = StringIO(b'foo=bar')
self.successResultOf(r.process())
self.assertEquals(r.fields[b'foo'].value, b'bar')
示例5: test_connectionLost
# 需要导入模块: from twisted.web.test.requesthelper import DummyChannel [as 别名]
# 或者: from twisted.web.test.requesthelper.DummyChannel import site [as 别名]
def test_connectionLost(self):
"""
L{Request.finish} is not called when the connection is lost before
rendering has finished.
"""
rendering = Deferred()
class Res(Render):
def renderHTTP(self, ctx):
return rendering
site = appserver.NevowSite(Res())
channel = DummyChannel()
channel.site = site
request = appserver.NevowRequest(channel, True)
request.connectionLost(Exception("Just Testing"))
rendering.callback(b"finished")
self.assertFalse(
request.finished, "Request was incorrectly marked as finished.")
示例6: renderResourceReturnTransport
# 需要导入模块: from twisted.web.test.requesthelper import DummyChannel [as 别名]
# 或者: from twisted.web.test.requesthelper.DummyChannel import site [as 别名]
def renderResourceReturnTransport(resource, path, method):
"""
Perform a synthetic request for the given resource. This is like
L{renderResource} but with a different return value.
@return: All of the bytes written to the transport as a result of the
rendering.
"""
s = appserver.NevowSite(resource)
channel = DummyChannel()
channel.site = s
r = appserver.NevowRequest(channel, True)
r.path = path
if method is not None:
r.method = method
d = r.process()
d.addCallback(lambda ignored: channel.transport.written.getvalue())
return d
示例7: renderResource
# 需要导入模块: from twisted.web.test.requesthelper import DummyChannel [as 别名]
# 或者: from twisted.web.test.requesthelper.DummyChannel import site [as 别名]
def renderResource(resource, path, method=None):
"""
Perform a synthetic request for the given resource.
@param resource: The L{nevow.inevow.IResource} from which to begin
processing.
@param path: The path of the url to use in processing.
@param method: An optional request method to use.
@return: The return value of L{NevowRequest.process} for this resource,
path, and method.
"""
s = appserver.NevowSite(resource)
channel = DummyChannel()
channel.site = s
r = appserver.NevowRequest(channel, True)
r.path = path
if method is not None:
r.method = method
return r.process()
示例8: createServer
# 需要导入模块: from twisted.web.test.requesthelper import DummyChannel [as 别名]
# 或者: from twisted.web.test.requesthelper.DummyChannel import site [as 别名]
def createServer(self, r):
chan = DummyChannel()
chan.site = server.Site(r)
return chan