From: Liang Ke Date: Mon, 26 Mar 2018 02:08:55 +0000 (+0000) Subject: Merge "Add test_get_res_from_aai" X-Git-Tag: v1.1.2~46 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=a2be701e860a06df93083888e7d5f8c64cea4183;hp=bb74f6c1fab0460686fb0985d27e48566a7fc693;p=multicloud%2Fframework.git Merge "Add test_get_res_from_aai" --- diff --git a/multivimbroker/multivimbroker/tests/test_restcall.py b/multivimbroker/multivimbroker/tests/test_restcall.py index b76b0a6..4ecf04e 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,21 @@ 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)