diff options
author | 2017-09-21 13:49:43 +0800 | |
---|---|---|
committer | 2017-09-21 13:49:43 +0800 | |
commit | 9a8b9e13f9dedda58fe68905976493d16961edfc (patch) | |
tree | 13c7bfc26b79fb75786e1aab55350b729faf6df1 | |
parent | d6eebb89ece12d2d8a304f24022cd0441d0914d5 (diff) |
Add deleting successfully nf test
Change-Id: I582119a0036741edf8cbda044dc8d9dbf9b3fa4b
Issue-Id: VFC-406
Signed-off-by: fengyuanxing <feng.yuanxing@zte.com.cn>
-rw-r--r-- | catalog/packages/tests.py | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/catalog/packages/tests.py b/catalog/packages/tests.py index b5e99d3c..b3a59757 100644 --- a/catalog/packages/tests.py +++ b/catalog/packages/tests.py @@ -181,35 +181,39 @@ class PackageTest(unittest.TestCase): @mock.patch.object(NfDistributeThread, 'get_vnfd') @mock.patch.object(nslcm,'get_vnfInstances') - def test_nf_package_delete_error(self, mock_get_vnfInstance, mock_get_vnfd): - # First distribute a VNF + def test_nf_package_delete_error(self, mock_get_vnfInstances, mock_get_vnfd): + # First distribute a VNF package local_file_name = "/url/local/filename" vnfd = json.JSONEncoder().encode(vnfd_json) mock_get_vnfd.return_value = vnfd_json,local_file_name,vnfd NfDistributeThread(str(self.nf_csarId), ["1"], "1", "4").run() self.assert_nfmodel_result(str(self.nf_csarId), 1) + # Then instantiate a VNF using this package + mock_get_vnfInstances.return_values = [{"csarid":"1"}] + # Delete it directly - mock_get_vnfInstance.return_values = [{"csarid":"1"}] self.assert_nfmodel_result("bb",0) NfPkgDeleteThread("bb", "6", False).run() self.assert_job_result("6", 100, "Error! CSAR(bb) does not exist.") - # - # - # @mock.patch.object(NfDistributeThread, 'get_vnfd') - # def test_nf_package_delete(self,mock_get_vnfd): - # # First distribute a VNF - # local_file_name = "/url/local/filename" - # vnfd = json.JSONEncoder().encode(vnfd_json) - # mock_get_vnfd.return_value = vnfd_json,local_file_name,vnfd - # - # NfDistributeThread("bb", ["1"], "1", "5").run() - # self.assert_job_result("5", 100, "CSAR(bb) distribute successfully.") - # self.assert_nfmodel_result("bb",1) - # - # # Then delete it - # NfPkgDeleteThread("bb", "6", False).run() - # self.assert_nfmodel_result("bb",0) + + + @mock.patch.object(NfDistributeThread, 'get_vnfd') + @mock.patch.object(nslcm,'get_vnfInstances') + def test_nf_package_delete(self,mock_get_vnfInstances,mock_get_vnfd): + # First distribute a VNF + local_file_name = "/url/local/filename" + vnfd = json.JSONEncoder().encode(vnfd_json) + mock_get_vnfd.return_value = vnfd_json,local_file_name,vnfd + + NfDistributeThread("bb", ["1"], "1", "5").run() + self.assert_job_result("5", 100, "CSAR(bb) distribute successfully.") + self.assert_nfmodel_result("bb",1) + + # Then delete the vnf + NfPkgDeleteThread("bb", "6", False).run() + self.assert_nfmodel_result("bb",0) + self.assert_job_result("6", 100, "Delete CSAR(bb) successfully.") def assert_job_result(self, job_id, job_progress, job_detail): jobs = JobStatusModel.objects.filter( |