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")))
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))
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))