Ejemplo n.º 1
0
 def test_post(self):
     "Test unknown API call return error code & message via POST"
     request = DummyRequest(api_mode="", api_version="", api_name="")
     request.setHeader("X-DigiTar-API-Version", "dummyapi")
     request.uri = "dummy.com/dummyapi/call"
     resource = urldispatch.UnknownCall()
     body = resource.render_POST(request)
     self.assertEquals(request.response_code, 404)
     self.assertEquals(request.getHeader("Content-Type"),
                       "application/json; charset=utf-8")
     self.assertEquals(body, str(webapi.UnknownAPICallError(request,
                                                            "call")))
Ejemplo n.º 2
0
 def test_post(self):
     "Test unknown API call return error code & message via POST"
     request = DummyRequest(api_mode="", api_version="", api_name="")
     request.setHeader("X-DigiTar-API-Version", "dummyapi")
     request.uri = "dummy.com/dummyapi/call"
     resource = urldispatch.UnknownCall()
     body = resource.render_POST(request)
     self.assertEquals(request.response_code, 404)
     self.assertEquals(request.getHeader("Content-Type"),
                       "application/json; charset=utf-8")
     self.assertEquals(body,
                       str(webapi.UnknownAPICallError(request, "call")))
Ejemplo n.º 3
0
 def test_match(self):
     request = DummyRequest(api_mode="", api_version="", api_name="")
     request.uri = "/example/"
     res = self.url_router.getChild("noname", request)
     self.assertTrue(isinstance(res, calls.PingCall))
Ejemplo n.º 4
0
 def test_no_match(self):
     request = DummyRequest(api_mode="", api_version="", api_name="")
     request.uri = "/notexample/"
     res = self.url_router.getChild("noname", request)
     self.assertTrue(isinstance(res, urldispatch.UnknownAPI))
Ejemplo n.º 5
0
 def test_match(self):
     request = DummyRequest(api_mode="", api_version="", api_name="")
     request.uri = "/example/"
     res = self.url_router.getChild("noname", request)
     self.assertTrue(isinstance(res, calls.PingCall))
Ejemplo n.º 6
0
 def test_no_match(self):
     request = DummyRequest(api_mode="", api_version="", api_name="")
     request.uri = "/notexample/"
     res = self.url_router.getChild("noname", request)
     self.assertTrue(isinstance(res, urldispatch.UnknownAPI))