diff options
Diffstat (limited to 'windriver/titanium_cloud/registration')
-rw-r--r-- | windriver/titanium_cloud/registration/tests/test_registration.py | 20 | ||||
-rw-r--r-- | windriver/titanium_cloud/registration/tests/test_registration2.py | 35 |
2 files changed, 31 insertions, 24 deletions
diff --git a/windriver/titanium_cloud/registration/tests/test_registration.py b/windriver/titanium_cloud/registration/tests/test_registration.py index 49df5b23..48d638d7 100644 --- a/windriver/titanium_cloud/registration/tests/test_registration.py +++ b/windriver/titanium_cloud/registration/tests/test_registration.py @@ -245,7 +245,7 @@ class TestRegistration(test_base.TestRequest): "registry"), TEST_REGISTER_ENDPOINT_REQUEST, HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID) - self.assertEquals(status.HTTP_202_ACCEPTED, + self.assertEqual(status.HTTP_202_ACCEPTED, response.status_code) # @mock.patch.object(VimDriverUtils, 'delete_vim_info') @@ -258,7 +258,7 @@ class TestRegistration(test_base.TestRequest): # "registry"), "{}", content_type="application/json", # HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID) - # self.assertEquals(status.HTTP_202_ACCEPTED, + # self.assertEqual(status.HTTP_202_ACCEPTED, # response.status_code) @mock.patch.object(VimDriverUtils, 'delete_vim_info') @@ -271,7 +271,7 @@ class TestRegistration(test_base.TestRequest): "registry"), "{}", content_type="application/json", HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID) - self.assertEquals(status.HTTP_204_NO_CONTENT, + self.assertEqual(status.HTTP_204_NO_CONTENT, response.status_code) @mock.patch.object(VimDriverUtils, 'get_session') @@ -301,7 +301,7 @@ class TestRegistration(test_base.TestRequest): "registry"), TEST_REGISTER_ENDPOINT_REQUEST, HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID) - self.assertEquals(status.HTTP_202_ACCEPTED, + self.assertEqual(status.HTTP_202_ACCEPTED, response.status_code) @mock.patch.object(VimDriverUtils, 'get_session') @@ -331,7 +331,7 @@ class TestRegistration(test_base.TestRequest): "registry"), TEST_REGISTER_ENDPOINT_REQUEST, HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID) - self.assertEquals(status.HTTP_202_ACCEPTED, + self.assertEqual(status.HTTP_202_ACCEPTED, response.status_code) @mock.patch.object(VimDriverUtils, 'get_session') @@ -361,7 +361,7 @@ class TestRegistration(test_base.TestRequest): "registry"), TEST_REGISTER_ENDPOINT_REQUEST, HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID) - self.assertEquals(status.HTTP_202_ACCEPTED, + self.assertEqual(status.HTTP_202_ACCEPTED, response.status_code) @mock.patch.object(VimDriverUtils, 'get_session') @@ -391,7 +391,7 @@ class TestRegistration(test_base.TestRequest): "registry"), TEST_REGISTER_ENDPOINT_REQUEST, HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID) - self.assertEquals(status.HTTP_202_ACCEPTED, + self.assertEqual(status.HTTP_202_ACCEPTED, response.status_code) @mock.patch.object(VimDriverUtils, 'get_session') @@ -421,7 +421,7 @@ class TestRegistration(test_base.TestRequest): "registry"), TEST_REGISTER_ENDPOINT_REQUEST, HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID) - self.assertEquals(status.HTTP_202_ACCEPTED, + self.assertEqual(status.HTTP_202_ACCEPTED, response.status_code) @mock.patch.object(VimDriverUtils, 'get_session') @@ -451,7 +451,7 @@ class TestRegistration(test_base.TestRequest): "registry"), TEST_REGISTER_ENDPOINT_REQUEST, HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID) - self.assertEquals(status.HTTP_202_ACCEPTED, + self.assertEqual(status.HTTP_202_ACCEPTED, response.status_code) @mock.patch.object(VimDriverUtils, 'get_session') @@ -481,5 +481,5 @@ class TestRegistration(test_base.TestRequest): "registry"), TEST_REGISTER_ENDPOINT_REQUEST, HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID) - self.assertEquals(status.HTTP_202_ACCEPTED, + self.assertEqual(status.HTTP_202_ACCEPTED, response.status_code) 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) |