From afd19e309b2a9361627704c51c385770f4bc3aaa Mon Sep 17 00:00:00 2001 From: Ethan Lynn Date: Wed, 13 Jun 2018 10:01:36 +0800 Subject: Add test_call_req_not_200 for rest_call Add test_call_req_not_200 for rest_call Change-Id: Ied82f6016191e6cdc1bce362bbc3ad536293276a Issue-ID: MULTICLOUD-199 Signed-off-by: Ethan Lynn --- vio/vio/tests/test_restcall.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/vio/vio/tests/test_restcall.py b/vio/vio/tests/test_restcall.py index 051dddf..08e38a9 100644 --- a/vio/vio/tests/test_restcall.py +++ b/vio/vio/tests/test_restcall.py @@ -64,3 +64,15 @@ class TestRestCall(unittest.TestCase): ret = restcall.call_req("http://onap.org/", "user", "pass", restcall.rest_no_auth, "vim", "GET") self.assertEqual(expect_ret, ret) + + @mock.patch("httplib2.Http.request") + def test_call_req_not_200(self, mock_req): + mock_resp = { + "status": "404" + } + resp_content = "hello" + mock_req.return_value = mock_resp, resp_content + expect_ret = [1, resp_content, "404", mock_resp] + ret = restcall.call_req("http://onap.org/", "user", "pass", + restcall.rest_no_auth, "vim", "GET") + self.assertEqual(expect_ret, ret) -- cgit 1.2.3-korg