diff options
author | Bin Yang <bin.yang@windriver.com> | 2019-08-20 10:01:12 +0000 |
---|---|---|
committer | Bin Yang <bin.yang@windriver.com> | 2019-08-21 03:02:23 +0000 |
commit | fbc00166dc021898a1a7dfb98672ec3bc28851b9 (patch) | |
tree | 789c60af42a259a5fb58753dc9e4485aea95db87 /windriver/titanium_cloud/registration/tests/test_registration2.py | |
parent | 4c33dac9a6735b07c5e7e0d2f67baa2f5eaeed97 (diff) |
Update windriver plugin to py3
Change-Id: I7bb1591a31de777d59ad1b96246bbc4d8e1f86f4
Issue-ID: MULTICLOUD-774
Signed-off-by: Bin Yang <bin.yang@windriver.com>
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) |