diff options
author | yangyan <yangyanyj@chinamobile.com> | 2019-08-21 11:03:50 +0800 |
---|---|---|
committer | yangyan <yangyanyj@chinamobile.com> | 2019-08-21 11:59:26 +0800 |
commit | 96adce9ff461501694dbc4ddf097b88c8695c3e8 (patch) | |
tree | 79f24519a0747c2679a812b08e1ae9b5c52cadc5 | |
parent | 4103c7b8245c2de4379a7663798a76611a9ec184 (diff) |
add unittest for ns_delete
Change-Id: I51642a2849bc4a88b0ea5a05ee767dab26d543db
Issue-ID: VFC-1489
Signed-off-by: yangyan <yangyanyj@chinamobile.com>
-rw-r--r-- | lcm/ns/tests/test_ns_delete.py | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/lcm/ns/tests/test_ns_delete.py b/lcm/ns/tests/test_ns_delete.py index d8ebf9ae..1d9a8e33 100644 --- a/lcm/ns/tests/test_ns_delete.py +++ b/lcm/ns/tests/test_ns_delete.py @@ -27,15 +27,31 @@ class TestNsDelete(TestCase): self.client = Client() self.ns_inst_id = str(uuid.uuid1()) NSInstModel.objects.filter().delete() - NSInstModel(id=self.ns_inst_id, nspackage_id="7", nsd_id="2").save() + NSInstModel(id=self.ns_inst_id, nspackage_id="7", nsd_id="2", name='name', + nsd_invariant_id='123', description='description', + sdncontroller_id='456', flavour_id='789').save() def tearDown(self): NSInstModel.objects.all().delete() @mock.patch.object(restcall, 'call_req') - def test_delete_ns(self, mock_call_req): + def test_delete_ns_in_aai(self, mock_call_req): r1_query_ns_to_aai = [0, json.JSONEncoder().encode(NS_INFO_AAI_DICT), '200'] r2_delete_ns_to_aai = [0, json.JSONEncoder().encode({}), '200'] mock_call_req.side_effect = [r1_query_ns_to_aai, r2_delete_ns_to_aai] response = self.client.delete("/api/nslcm/v1/ns/%s" % self.ns_inst_id) self.assertEqual(status.HTTP_204_NO_CONTENT, response.status_code) + + @mock.patch.object(restcall, 'call_req') + def test_delete_ns_in_databases(self, mock_call_req): + data = NSInstModel.objects.filter() + if data: + data = NSInstModel.objects.filter().delete() + else: + data = {} + delet_ns_in_database = [0, data, '200'] + query_data = NSInstModel.objects.filter() + query_ns_in_database = [0, query_data, '200'] + mock_call_req.side_effect = [delet_ns_in_database, query_ns_in_database] + response = self.client.delete("/api/nslcm/v1/ns/%s" % self.ns_inst_id) + self.assertEqual(status.HTTP_204_NO_CONTENT, response.status_code) |