Пример #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")))
Пример #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")))
Пример #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))
Пример #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))
Пример #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))
Пример #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))