def test_notFoundRender(self): """ If the source file a L{PythonScript} is initialized with doesn't exist, L{PythonScript.render} sets the HTTP response code to I{NOT FOUND}. """ resource = PythonScript(self.mktemp(), None) request = DummyRequest([b""]) d = _render(resource, request) def cbRendered(ignored): self.assertEqual(request.responseCode, NOT_FOUND) d.addCallback(cbRendered) return d
def test_renderException(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() child = tmp.child("test.epy") child.setContent(b'raise Exception("nooo")') resource = PythonScript(child._asBytesPath(), None) request = DummyRequest([b""]) d = _render(resource, request) def cbRendered(ignored): self.assertIn(b"nooo", b"".join(request.written)) d.addCallback(cbRendered) return d