Esempio n. 1
0
    def test_EmbeddedSaratogaWithRegex(self):

        def rendered(res, request):
            self.assertEqual(
                json.loads(request.getWrittenData()),
                {"status": "success", "data": {"id": "4"}}
            )

        r = Resource()
        r.putChild("api", self.api.getResource())
        req = requestMock("/api/v1/example/4")
        endup = getChildForRequest(r, req)
        d = _render(endup, req)
        d.addCallback(rendered, req)
        return r
Esempio n. 2
0
    def test_EmbeddedSaratogaWithRegex404(self):

        def rendered(res, request):
            self.assertEqual(
                json.loads(request.getWrittenData()),
                {"status": "fail", "data": "Bad ID :("}
            )
            warnings = self.flushLoggedErrors()
            self.assertEqual(len(warnings), 1)

        r = Resource()
        r.putChild("api", self.api.getResource())
        req = requestMock("/api/v1/example/9999")
        endup = getChildForRequest(r, req)
        d = _render(endup, req)
        d.addCallback(rendered, req)
        return r