X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=multivimbroker%2Fmultivimbroker%2Ftests%2Ftest_restcall.py;h=ea70dff14da5ee66544641da754bdd489950b18f;hb=ffb081ac0880987d1ab8ea11c90e52eb8a8d1db5;hp=235d58ac0669824d6b37782b2b7ca713f094ce1a;hpb=98d67a40a0c961cecb7dcc044846a6f3bddb53ba;p=multicloud%2Fframework.git diff --git a/multivimbroker/multivimbroker/tests/test_restcall.py b/multivimbroker/multivimbroker/tests/test_restcall.py index 235d58a..ea70dff 100644 --- a/multivimbroker/multivimbroker/tests/test_restcall.py +++ b/multivimbroker/multivimbroker/tests/test_restcall.py @@ -18,8 +18,8 @@ class TestRestCall(unittest.TestCase): def test_combine_url(self): url = ["http://a.com/test/", "http://a.com/test/", - "http://a.com/test"] - res = ["/resource", "resource", "/resource"] + "http://a.com/test", "http://a.com/test"] + res = ["/resource", "resource", "/resource", "resource"] expected = "http://a.com/test/resource" for i in range(len(url)): self.assertEqual(expected, restcall.combine_url(url[i], res[i])) @@ -49,7 +49,19 @@ class TestRestCall(unittest.TestCase): content = "no content" headers = None restcall.req_by_msb(res, method, content=content, headers=headers) - expect_url = "http://127.0.0.1:10080/" + expect_url = "http://msb.onap.org:10080/" mock_call.assert_called_once_with( expect_url, "", "", restcall.rest_no_auth, res, method, content, headers) + + @mock.patch("httplib2.Http.request") + def test_call_req_success(self, mock_req): + mock_resp = { + "status": "200" + } + resp_content = "hello" + mock_req.return_value = mock_resp, resp_content + expect_ret = [0, resp_content, "200", mock_resp] + ret = restcall.call_req("http://onap.org/", "user", "pass", + restcall.rest_no_auth, "vim", "GET") + self.assertEqual(expect_ret, ret)