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


Python requesthelper.DummyChannel类代码示例

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


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

示例1: renderResource

 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()
开发者ID:mithrandi,项目名称:nevow,代码行数:7,代码来源:test_appserver.py

示例2: testPrePathURLSSLNonDefault

 def testPrePathURLSSLNonDefault(self):
     d = DummyChannel()
     d.transport = DummyChannel.SSL()
     d.transport.port = 81
     request = server.Request(d, 1)
     request.setHost(b'example.com', 81)
     request.gotLength(0)
     request.requestReceived(b'GET', b'/foo/bar', b'HTTP/1.0')
     self.assertEqual(request.prePathURL(), b'https://example.com:81/foo/bar')
开发者ID:AlexanderHerlan,项目名称:syncpy,代码行数:9,代码来源:test_web.py

示例3: testPrePathURLHTTPPortAndSSL

 def testPrePathURLHTTPPortAndSSL(self):
     d = DummyChannel()
     d.transport = DummyChannel.SSL()
     d.transport.port = 80
     request = server.Request(d, 1)
     request.setHost('example.com', 80)
     request.gotLength(0)
     request.requestReceived('GET', '/foo/bar', 'HTTP/1.0')
     self.assertEqual(request.prePathURL(), 'https://example.com:80/foo/bar')
开发者ID:anrysev,项目名称:twisted,代码行数:9,代码来源:test_web.py

示例4: create_request

 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
开发者ID:pixelated,项目名称:pixelated-user-agent,代码行数:11,代码来源:test_site.py

示例5: getTextOfPage

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()
开发者ID:chevah,项目名称:pydoctor,代码行数:13,代码来源:test_server.py

示例6: test_renderPOST

    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')
开发者ID:twisted,项目名称:nevow,代码行数:18,代码来源:test_appserver.py

示例7: test_connectionLost

    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.")
开发者ID:twisted,项目名称:nevow,代码行数:18,代码来源:test_appserver.py

示例8: renderResourceReturnTransport

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
开发者ID:twisted,项目名称:nevow,代码行数:18,代码来源:test_appserver.py

示例9: renderResource

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()
开发者ID:twisted,项目名称:nevow,代码行数:22,代码来源:test_appserver.py

示例10: createServer

 def createServer(self, r):
     chan = DummyChannel()
     chan.site = server.Site(r)
     return chan
开发者ID:AlexanderHerlan,项目名称:syncpy,代码行数:4,代码来源:test_web.py


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