diff options
author | 2018-11-10 12:48:44 +0000 | |
---|---|---|
committer | 2018-11-10 12:59:35 +0000 | |
commit | ce3fffda433531666295e5c9b3148e9128e57f16 (patch) | |
tree | 085a51687d1f28ccc6d1ba04ce8bafd92b064563 /windriver/titanium_cloud/resource/tests/tests_infra_workload.py | |
parent | 5eea270e67a262e9ace8637cb54307c23d247066 (diff) |
Support infra_workload api without oof_directives
Change-Id: I8eb05ff2acdef8811b3eec8e1a0efe47b12bdd73
Issue-ID: MULTICLOUD-401
Signed-off-by: Bin Yang <bin.yang@windriver.com>
Diffstat (limited to 'windriver/titanium_cloud/resource/tests/tests_infra_workload.py')
-rw-r--r-- | windriver/titanium_cloud/resource/tests/tests_infra_workload.py | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/windriver/titanium_cloud/resource/tests/tests_infra_workload.py b/windriver/titanium_cloud/resource/tests/tests_infra_workload.py index 2d75e595..1ace4f99 100644 --- a/windriver/titanium_cloud/resource/tests/tests_infra_workload.py +++ b/windriver/titanium_cloud/resource/tests/tests_infra_workload.py @@ -116,6 +116,47 @@ MOCK_HEAT_LIST_RESPONSE1 = { ] } + +MOCK_HEAT_CREATE_BODY2 = { + "generic-vnf-id":"MOCK_GENERIF_VNF_ID1", + "vf-module-id":"MOCK_VF_MODULE_ID1", + "template_type":"HEAT", + "template_data":{ + "files":{ }, + "disable_rollback":True, + "parameters":{ + "flavor1":"m1.heat" + }, + "stack_name":"teststack", + "template":{ + "heat_template_version":"2013-05-23", + "description":"Simple template to test heat commands", + "parameters": + { + "flavor":{ + "default":"m1.tiny", + "type":"string" + } + }, + "resources":{ + "hello_world":{ + "type":"OS::Nova::Server", + "properties":{ + "key_name":"heat_key", + "flavor":{ + "get_param":"flavor" + }, + "image":"40be8d1a-3eb9-40de-8abd-43237517384f", + "user_data":"#!/bin/bash -xv\necho \"hello world\" > /root/hello-world.txt\n" + } + } + } + }, + "timeout_mins":60 + } +} + + class InfraWorkloadTest(unittest.TestCase): def setUp(self): self._InfraWorkload = InfraWorkload() @@ -148,6 +189,27 @@ class InfraWorkloadTest(unittest.TestCase): @mock.patch.object(helper, 'MultiCloudServiceHelper') @mock.patch.object(helper, 'MultiCloudIdentityHelper') + def test_post_wo_oof_directive(self, mock_MultiCloudIdentityHelper, mock_MultiCloudServiceHelper): + mock_request = mock.Mock() + mock_request.META = {"testkey": "testvalue"} + mock_request.data = MOCK_HEAT_CREATE_BODY2 + + mock_MultiCloudIdentityHelper.side_effect= [ + (0, MOCK_TOKEN_RESPONSE, status.HTTP_201_CREATED) + ] + + mock_MultiCloudServiceHelper.side_effect= [ + (0, MOCK_HEAT_CREATE_RESPONSE1, status.HTTP_201_CREATED) + ] + + vimid = "CloudOwner_Region1" + + response = self._InfraWorkload.post(mock_request, vimid) + self.assertEqual(response.status_code, status.HTTP_201_CREATED) + pass + + @mock.patch.object(helper, 'MultiCloudServiceHelper') + @mock.patch.object(helper, 'MultiCloudIdentityHelper') def test_get(self, mock_MultiCloudIdentityHelper, mock_MultiCloudServiceHelper): mock_request = mock.Mock() mock_request.META = {"testkey": "testvalue"} |