summaryrefslogtreecommitdiffstats
path: root/newton
diff options
context:
space:
mode:
authorYun Huang <yun.huang@windriver.com>2018-03-22 22:07:14 +0800
committerYun Huang <yun.huang@windriver.com>2018-03-22 22:07:14 +0800
commit6e16b90e3241156724d0f2df73a3c807b0794842 (patch)
tree99ee67399f9c2d480d298846f953e40927820bdb /newton
parent32ba3fcdad5cab9a25e0e53ac7cfbe807fdef70c (diff)
Newton UT for capacity check nova limits failed
Change-Id: Ied372034ada4cd417f8dccd982b09b3b2b489ee3 Issue-ID: MULTICLOUD-168 Signed-off-by: Yun Huang <yun.huang@windriver.com>
Diffstat (limited to 'newton')
-rw-r--r--newton/.gitignore2
-rw-r--r--newton/newton/resource/tests/test_capacity.py28
2 files changed, 30 insertions, 0 deletions
diff --git a/newton/.gitignore b/newton/.gitignore
index d0dc4903..224c808e 100644
--- a/newton/.gitignore
+++ b/newton/.gitignore
@@ -15,3 +15,5 @@ openstack_multicloud.egg-info/
.eggs/
build/
test-reports/
+coverage.xml
+
diff --git a/newton/newton/resource/tests/test_capacity.py b/newton/newton/resource/tests/test_capacity.py
index 605aed8b..071997e3 100644
--- a/newton/newton/resource/tests/test_capacity.py
+++ b/newton/newton/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)
+