X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=multivimbroker%2Fmultivimbroker%2Ftests%2Ftest_restcall.py;h=235d58ac0669824d6b37782b2b7ca713f094ce1a;hb=382204d0cc69fcd33f734ff3e172dcb5d5515b6b;hp=b76b0a606b167eeea486a31d1e440e5dd7e8cf13;hpb=e24c74a1f89d29ed30ad806955bf2ee077361fd5;p=multicloud%2Fframework.git diff --git a/multivimbroker/multivimbroker/tests/test_restcall.py b/multivimbroker/multivimbroker/tests/test_restcall.py index b76b0a6..235d58a 100644 --- a/multivimbroker/multivimbroker/tests/test_restcall.py +++ b/multivimbroker/multivimbroker/tests/test_restcall.py @@ -8,6 +8,7 @@ # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +import mock import unittest from multivimbroker.pub.utils import restcall @@ -22,3 +23,33 @@ class TestRestCall(unittest.TestCase): expected = "http://a.com/test/resource" for i in range(len(url)): self.assertEqual(expected, restcall.combine_url(url[i], res[i])) + + @mock.patch.object(restcall, "call_req") + def test_get_res_from_aai(self, mock_call): + res = "cloud-regions" + content = "" + expect_url = "https://aai.api.simpledemo.openecomp.org:8443/aai/v13" + expect_user = "AAI" + expect_pass = "AAI" + expect_headers = { + 'X-FromAppId': 'MultiCloud', + 'X-TransactionId': '9001', + 'content-type': 'application/json', + 'accept': 'application/json' + } + restcall.get_res_from_aai(res, content=content) + mock_call.assert_called_once_with( + expect_url, expect_user, expect_pass, restcall.rest_no_auth, + res, "GET", content, expect_headers) + + @mock.patch.object(restcall, "call_req") + def test_req_by_msb(self, mock_call): + res = "multicloud" + method = "GET" + content = "no content" + headers = None + restcall.req_by_msb(res, method, content=content, headers=headers) + expect_url = "http://127.0.0.1:10080/" + mock_call.assert_called_once_with( + expect_url, "", "", restcall.rest_no_auth, res, method, + content, headers)