summaryrefslogtreecommitdiffstats
path: root/pike
diff options
context:
space:
mode:
authorHuang Haibin <haibin.huang@intel.com>2018-09-20 10:33:18 +0800
committerHuang Haibin <haibin.huang@intel.com>2018-09-20 10:33:18 +0800
commitdab0c9f0edb0d2df7828009babb6686f625ad0c4 (patch)
tree77dc8064d1c3ee3b519c90280edbeb5cb04fe096 /pike
parentcc85b26ca7084353cdb6a5f91f8df0c92e0d5d32 (diff)
Add UT for infra_workload delete API
Change-Id: I16da96a19eff471dca0b8a6f47fe8a95d063598e Issue-ID: MULTICLOUD-250 Signed-off-by: Huang Haibin <haibin.huang@intel.com>
Diffstat (limited to 'pike')
-rw-r--r--pike/pike/resource/tests/tests_infra_workload.py45
-rw-r--r--pike/pike/resource/views/infra_workload.py2
2 files changed, 46 insertions, 1 deletions
diff --git a/pike/pike/resource/tests/tests_infra_workload.py b/pike/pike/resource/tests/tests_infra_workload.py
index 51fd0837..48c29d15 100644
--- a/pike/pike/resource/tests/tests_infra_workload.py
+++ b/pike/pike/resource/tests/tests_infra_workload.py
@@ -159,6 +159,28 @@ class InfraWorkloadTest(unittest.TestCase):
pass
+ @mock.patch.object(helper, 'MultiCloudServiceHelper')
+ @mock.patch.object(helper, 'MultiCloudIdentityHelper')
+ def test_delete(self, mock_MultiCloudIdentityHelper, mock_MultiCloudServiceHelper):
+ mock_request = mock.Mock()
+ mock_request.META = {"testkey": "testvalue"}
+
+ mock_MultiCloudIdentityHelper.side_effect= [
+ (0, MOCK_TOKEN_RESPONSE, status.HTTP_201_CREATED)
+ ]
+
+ mock_MultiCloudServiceHelper.side_effect= [
+ (0, MOCK_HEAT_LIST_RESPONSE1, status.HTTP_200_OK)
+ ]
+
+ vimid = "CloudOwner_Region1"
+ mock_stack_id = "MOCKED_HEAT_STACK_ID1"
+
+ response = self._InfraWorkload.delete(mock_request, vimid, mock_stack_id)
+ self.assertEqual(response.status_code, status.HTTP_200_OK)
+ pass
+
+
class APIv1InfraWorkloadTest(unittest.TestCase):
def setUp(self):
self._APIv1InfraWorkload = APIv1InfraWorkload()
@@ -212,3 +234,26 @@ class APIv1InfraWorkloadTest(unittest.TestCase):
response = self._APIv1InfraWorkload.get(mock_request, cloud_owner, cloud_region_id, mock_stack_id)
self.assertEqual(response.status_code, status.HTTP_200_OK)
pass
+
+
+ @mock.patch.object(helper, 'MultiCloudServiceHelper')
+ @mock.patch.object(helper, 'MultiCloudIdentityHelper')
+ def test_delete(self, mock_MultiCloudIdentityHelper, mock_MultiCloudServiceHelper):
+ mock_request = mock.Mock()
+ mock_request.META = {"testkey": "testvalue"}
+
+ mock_MultiCloudIdentityHelper.side_effect= [
+ (0, MOCK_TOKEN_RESPONSE, status.HTTP_201_CREATED)
+ ]
+
+ mock_MultiCloudServiceHelper.side_effect= [
+ (0, MOCK_HEAT_LIST_RESPONSE1, status.HTTP_200_OK)
+ ]
+
+ cloud_owner = "CloudOwner"
+ cloud_region_id = "Region1"
+ mock_stack_id = "MOCKED_HEAT_STACK_ID1"
+
+ response = self._APIv1InfraWorkload.delete(mock_request, cloud_owner, cloud_region_id, mock_stack_id)
+ self.assertEqual(response.status_code, status.HTTP_200_OK)
+ pass
diff --git a/pike/pike/resource/views/infra_workload.py b/pike/pike/resource/views/infra_workload.py
index 80cb112e..3e144e7f 100644
--- a/pike/pike/resource/views/infra_workload.py
+++ b/pike/pike/resource/views/infra_workload.py
@@ -303,7 +303,7 @@ class InfraWorkload(APIView):
return aai_transactions
def delete(self, request, vimid="", requri=""):
- self._logger.info("vimid, requri: %s" % (vimid, requri))
+ self._logger.info("vimid, requri: %s, %s" % (vimid, requri))
self._logger.debug("META: %s" % request.META)
try :