diff options
author | fengyuanxing <feng.yuanxing@zte.com.cn> | 2017-09-01 14:59:24 +0800 |
---|---|---|
committer | fengyuanxing <feng.yuanxing@zte.com.cn> | 2017-09-01 14:59:24 +0800 |
commit | dd282a45284c0cd2212d2745dad3461e282af2be (patch) | |
tree | 9c91af4b10504aeee189c39cf419f0eeadb6fc88 | |
parent | c04406d6cf9401e2178042482f19200cc336f8dd (diff) |
Add code of deleting nf ahead of ns
Change-Id: I5360347b7221a3ab7d4c05c409b82f869ccb4569
Issue-Id: VFC-222
Signed-off-by: fengyuanxing <feng.yuanxing@zte.com.cn>
-rw-r--r-- | catalog/packages/tests.py | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/catalog/packages/tests.py b/catalog/packages/tests.py index 9bb5ea09..cbee46a6 100644 --- a/catalog/packages/tests.py +++ b/catalog/packages/tests.py @@ -494,11 +494,31 @@ class PackageTest(unittest.TestCase): self.assert_job_result("5", 100, "CSAR(dd) distribute successfully.") NfPackageModel.objects.filter(nfpackageid="dd").delete() + @mock.patch.object(NfDistributeThread, 'get_vnfd') + @mock.patch.object(NsPackage,'get_nsd') + def test_ns_package_delete(self, mock_get_nsd,mock_get_vnfd): - def test_ns_package_delete(self): - response = self.client.delete("/api/catalog/v1/nspackages/" + str(self.ns_csarId)) + # First distribute a VNF + local_file_name = "/url/local/filename" + vnfd = json.JSONEncoder().encode(self.vnfd_json) + mock_get_vnfd.return_value = self.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 distribute a NS associated with the below VNF + local_file_name = "/url/local/filename" + nsd = json.JSONEncoder().encode(self.nsd_json) + mock_get_nsd.return_value = self.nsd_json,local_file_name,nsd + response = self.client.delete("/api/catalog/v1/nspackages/%s" % str(self.ns_csarId)) self.assertEqual(status.HTTP_202_ACCEPTED, response.status_code, response.content) + self.assertEqual("Delete CSAR(123) successfully.", response.data["statusDescription"], response.content) + self.assert_nfmodel_result(str(self.ns_csarId), 0) + self.assert_nsdmodel_result("VCPE_NS", 0) + # Finally delete ns package + response = self.client.delete("/api/catalog/v1/nspackages/" + str(self.ns_csarId)) + self.assertEqual(status.HTTP_202_ACCEPTED, response.status_code, response.content) + self.assert_nsdmodel_result("VCPE_NS", 0) def test_nf_package_delete_error(self): # Delete it directly |