diff options
author | fengyuanxing <feng.yuanxing@zte.com.cn> | 2017-08-31 18:55:01 +0800 |
---|---|---|
committer | fengyuanxing <feng.yuanxing@zte.com.cn> | 2017-08-31 18:55:01 +0800 |
commit | 1c9255b3dc5ae4887dec7138f20d505ea37b382f (patch) | |
tree | d33e57aedebdd4a4597c99776d49e4ca9f31cb04 | |
parent | 3d654af2e0d77d4fd73c70ea2314bd231af72334 (diff) |
Modify test code deleting model objects
Change-Id: Idf5d616317e5080b32e44696fce89407c042237d
Issue-Id: VFC-152
Signed-off-by: fengyuanxing <feng.yuanxing@zte.com.cn>
-rw-r--r-- | catalog/packages/tests.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/catalog/packages/tests.py b/catalog/packages/tests.py index 6629fdbc..6180b003 100644 --- a/catalog/packages/tests.py +++ b/catalog/packages/tests.py @@ -452,7 +452,9 @@ class PackageTest(unittest.TestCase): response = self.client.post("/api/catalog/v1/nspackages",self.nsdata) self.assertEqual(status.HTTP_202_ACCEPTED, response.status_code, response.content) - self.assertIsNotNone(NSDModel.objects.filter(id=self.ns_csarId)) + self.assert_nsdmodel_result("VCPE_NS", 0) + self.assertEqual("VNF package(456) is not distributed.", response.data["statusDescription"], response.content) + NSDModel.objects.filter(id="VCPE_NS").delete() def test_nfpackages_get(self): response = self.client.get("/api/catalog/v1/vnfpackages") @@ -478,6 +480,9 @@ class PackageTest(unittest.TestCase): response = self.client.post("/api/catalog/v1/nspackages",self.nsdata) self.assertEqual(status.HTTP_202_ACCEPTED, response.status_code, response.content) self.assertEqual("CSAR(123) distributed successfully.", response.data["statusDescription"], response.content) + self.assert_nsdmodel_result("VCPE_NS", 1) + NfPackageModel.objects.filter(vnfdid=str(self.nf_csarId)).delete() + NSDModel.objects.filter(nsd_id="VCPE_NS").delete() @mock.patch.object(NfDistributeThread, 'get_vnfd') def test_nf_distribute(self, mock_get_vnfd): @@ -487,6 +492,7 @@ class PackageTest(unittest.TestCase): NfDistributeThread("dd", ["1"], "1", "5").run() self.assert_job_result("5", 100, "CSAR(dd) distribute successfully.") + NSDModel.objects.filter(id="dd").delete() def test_ns_package_delete(self): @@ -504,3 +510,10 @@ class PackageTest(unittest.TestCase): progress=job_progress, descp=job_detail) self.assertEqual(1, len(jobs)) + + def assert_nsdmodel_result(self,nsd_id,size): + nsdmodels = NSDModel.objects.filter( + nsd_id = nsd_id + ) + + self.assertEquals(size, len(nsdmodels)) |