diff options
Diffstat (limited to 'windriver/titanium_cloud/registration/tests/test_registration2.py')
-rw-r--r-- | windriver/titanium_cloud/registration/tests/test_registration2.py | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/windriver/titanium_cloud/registration/tests/test_registration2.py b/windriver/titanium_cloud/registration/tests/test_registration2.py index e00c6adc..1072b373 100644 --- a/windriver/titanium_cloud/registration/tests/test_registration2.py +++ b/windriver/titanium_cloud/registration/tests/test_registration2.py @@ -12,9 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -import mock - +# import mock import unittest +from unittest import mock + # import json from django.test import Client from rest_framework import status @@ -72,6 +73,7 @@ MOCK_GET_FLAVOR_EXTRASPECS_RESPONSE_w_hpa_numa = { } + class TestRegistration2(unittest.TestCase): def setUp(self): self.client = Client() @@ -84,25 +86,30 @@ class TestRegistration2(unittest.TestCase): restcall.req_to_aai = mock.Mock() restcall.req_to_aai.return_value = (0, {}, status.HTTP_200_OK) mock_session = test_base.get_mock_session( - ["get"], {"get": { - "content": MOCK_GET_FLAVOR_RESPONSE}}), - - retcode, content = self.view.register_helper._discover_flavors(vimid="windriver-hudson-dc_RegionOne", + ["get"], { + "side_effect": [ + test_base.get_mock_response(MOCK_GET_FLAVOR_RESPONSE) + ] + }) + retcode, content = self.view.register_helper._discover_flavors( + vimid="windriver-hudson-dc_RegionOne", session=mock_session, viminfo=MOCK_VIM_INFO) - self.assertEquals(retcode, 11) + self.assertEqual(retcode, 0) def test_discover_flavors_w_hpa_numa(self): restcall.req_to_aai = mock.Mock() restcall.req_to_aai.return_value = (0, {}, status.HTTP_200_OK) mock_session = test_base.get_mock_session( - ["get"], {"side_effect": [{ - "content": MOCK_GET_FLAVOR_RESPONSE_w_hpa_numa}, - { - "content": MOCK_GET_FLAVOR_EXTRASPECS_RESPONSE_w_hpa_numa} - ]}), + ["get"], { + "side_effect": [ + test_base.get_mock_response(MOCK_GET_FLAVOR_RESPONSE_w_hpa_numa), + test_base.get_mock_response(MOCK_GET_FLAVOR_EXTRASPECS_RESPONSE_w_hpa_numa), + ] + }) - retcode, content = self.view.register_helper._discover_flavors(vimid="windriver-hudson-dc_RegionOne", + retcode, content = self.view.register_helper._discover_flavors( + vimid="windriver-hudson-dc_RegionOne", session=mock_session, viminfo=MOCK_VIM_INFO) - self.assertEquals(retcode, 11) + self.assertEqual(retcode, 0) |