From e5dc5b3a2780055d37f82f25b49ad0b68f0af20e Mon Sep 17 00:00:00 2001 From: Yun Huang Date: Thu, 22 Mar 2018 14:53:24 +0800 Subject: Windriver UT for capacity check nova limits failed Change-Id: I7d03aff43bc97dad895b63ddfb6efd2185ad0810 Issue-ID: MULTICLOUD-168 Signed-off-by: Yun Huang --- .../titanium_cloud/resource/tests/test_capacity.py | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'windriver/titanium_cloud/resource/tests') diff --git a/windriver/titanium_cloud/resource/tests/test_capacity.py b/windriver/titanium_cloud/resource/tests/test_capacity.py index 605aed8b..3dae1080 100644 --- a/windriver/titanium_cloud/resource/tests/test_capacity.py +++ b/windriver/titanium_cloud/resource/tests/test_capacity.py @@ -58,6 +58,13 @@ 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 +97,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) + -- cgit 1.2.3-korg