From c72e0f4a8fc3886351291a169470217612641315 Mon Sep 17 00:00:00 2001 From: Yun Huang Date: Wed, 28 Mar 2018 12:14:09 +0800 Subject: Add TC capacity_check_volume_limits_outofstorage Change-Id: Ifdcf210cc49713bf6d183146a2da402238fde9ae Issue-ID: MULTICLOUD-203 Signed-off-by: Yun Huang --- .../titanium_cloud/resource/tests/test_capacity.py | 33 ++++++++++++++++++++++ 1 file changed, 33 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 14840832..b112818f 100644 --- a/windriver/titanium_cloud/resource/tests/test_capacity.py +++ b/windriver/titanium_cloud/resource/tests/test_capacity.py @@ -43,6 +43,16 @@ MOCK_GET_HYPER_STATATICS_RESPONSE = { } } +MOCK_GET_STORAGE_RESPONSE_OOS = { + "limits": { + "rate": [], + "absolute": { + "totalGigabytesUsed": 498, + "maxTotalVolumeGigabytes": 500, + } + } +} + MOCK_GET_HYPER_STATATICS_RESPONSE_OUTOFVCPU = { "hypervisor_statistics": { "vcpus_used": 9, @@ -241,3 +251,26 @@ class TestCapacity(test_base.TestRequest): data=json.dumps(TEST_REQ_SUCCESS_SOURCE), content_type='application/json', HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID) + + @mock.patch.object(VimDriverUtils, 'get_session') + @mock.patch.object(VimDriverUtils, 'get_vim_info') + def test_capacity_check_volume_limits_outofstorage(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_OOS), + ] + }) + + response = self.client.post( + "/api/multicloud-titanium_cloud/v0/windriver-hudson-dc_RegionOne/capacity_check", + data=json.dumps(TEST_REQ_SUCCESS_SOURCE), + content_type='application/json', + 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