def test_render(self): """ L{ResourceScriptDirectory.getChild} returns a resource which renders a response with the HTTP 200 status code and the content of the rpy's C{request} global. """ tmp = FilePath(self.mktemp()) tmp.makedirs() tmp.child("test.rpy").setContent(b""" from twisted.web.resource import Resource class TestResource(Resource): isLeaf = True def render_GET(self, request): return b'ok' resource = TestResource()""") resource = ResourceScriptDirectory(tmp._asBytesPath()) request = DummyRequest([b""]) child = resource.getChild(b"test.rpy", request) d = _render(child, request) def cbRendered(ignored): self.assertEqual(b"".join(request.written), b"ok") d.addCallback(cbRendered) return d
def test_render(self): """ L{ResourceScriptDirectory.getChild} returns a resource which renders a response with the HTTP 200 status code and the content of the rpy's C{request} global. """ tmp = FilePath(self.mktemp()) tmp.makedirs() tmp.child("test.rpy").setContent(b""" from twisted.web.resource import Resource class TestResource(Resource): isLeaf = True def render_GET(self, request): return b'ok' resource = TestResource()""") resource = ResourceScriptDirectory(tmp._asBytesPath()) request = DummyRequest([b'']) child = resource.getChild(b"test.rpy", request) d = _render(child, request) def cbRendered(ignored): self.assertEqual(b"".join(request.written), b"ok") d.addCallback(cbRendered) return d