diff options
author | Yun Huang <yun.huang@windriver.com> | 2018-03-22 21:56:53 +0800 |
---|---|---|
committer | Yun Huang <yun.huang@windriver.com> | 2018-03-22 21:56:53 +0800 |
commit | 32ba3fcdad5cab9a25e0e53ac7cfbe807fdef70c (patch) | |
tree | a5486be00bab44f2312405a54ad8181eca04d12a /ocata | |
parent | e5dc5b3a2780055d37f82f25b49ad0b68f0af20e (diff) |
Ocata UT for capacity check nova limits failed
Change-Id: I35ada8f65c37fadf47dc36fa05e209bbde5726ed
Issue-ID: MULTICLOUD-168
Signed-off-by: Yun Huang <yun.huang@windriver.com>
Diffstat (limited to 'ocata')
-rw-r--r-- | ocata/.gitignore | 2 | ||||
-rw-r--r-- | ocata/ocata/resource/tests/test_capacity.py | 28 |
2 files changed, 30 insertions, 0 deletions
diff --git a/ocata/.gitignore b/ocata/.gitignore index e86d02b0..06570027 100644 --- a/ocata/.gitignore +++ b/ocata/.gitignore @@ -8,4 +8,6 @@ logs/*.log .tox .coverage htmlcov/ +coverage.xml +test-reports/ diff --git a/ocata/ocata/resource/tests/test_capacity.py b/ocata/ocata/resource/tests/test_capacity.py index 605aed8b..071997e3 100644 --- a/ocata/ocata/resource/tests/test_capacity.py +++ b/ocata/ocata/resource/tests/test_capacity.py @@ -58,6 +58,12 @@ TEST_REQ_SUCCESS_SOURCE = { "Storage": "200" } +TEST_REQ_FAILED_SOURCE = { + "vCPU": "17", + "Memory": "4096", + "Storage": "200" +} + class TestCapacity(test_base.TestRequest): def setUp(self): super(TestCapacity, self).setUp() @@ -90,3 +96,25 @@ class TestCapacity(test_base.TestRequest): self.assertEquals(status.HTTP_200_OK, response.status_code) self.assertEqual({"result": True}, response.data) + @mock.patch.object(VimDriverUtils, 'get_session') + @mock.patch.object(VimDriverUtils, 'get_vim_info') + def test_capacity_check_nova_limits_failed(self, mock_get_vim_info, mock_get_session): + mock_get_vim_info.return_value = mock_info.MOCK_VIM_INFO + mock_get_session.return_value = test_base.get_mock_session( + ["get"], { + "side_effect": [ + self._get_mock_response(MOCK_GET_TENANT_LIMIT_RESPONSE), + self._get_mock_response(MOCK_GET_HYPER_STATATICS_RESPONSE), + self._get_mock_response(MOCK_GET_STORAGE_RESPONSE), + ] + }) + + response = self.client.post(( + "/api/%s/v0/windriver-hudson-dc_RegionOne/" + "capacity_check" % test_base.MULTIVIM_VERSION), + TEST_REQ_FAILED_SOURCE, + HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID) + + self.assertEquals(status.HTTP_200_OK, response.status_code) + self.assertEqual({"result": False}, response.data) + |