From: fujinhua Date: Mon, 13 Aug 2018 03:53:13 +0000 (+0800) Subject: Refactor unit test for ns heal X-Git-Tag: 1.2.0~83 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=4dd69a8de6fe05e45e7ce898d1b0f30d56b7e63c;p=vfc%2Fnfvo%2Flcm.git Refactor unit test for ns heal Change-Id: I0dc241dc05c191e3d8d086d9071c8a227c964e56 Issue-ID: VFC-1009 Signed-off-by: fujinhua --- diff --git a/lcm/ns/tests/test_ns_heal.py b/lcm/ns/tests/test_ns_heal.py index a3b8498e..8d2f93a6 100644 --- a/lcm/ns/tests/test_ns_heal.py +++ b/lcm/ns/tests/test_ns_heal.py @@ -13,6 +13,7 @@ # limitations under the License. import mock +import json from rest_framework import status from django.test import TestCase @@ -35,19 +36,40 @@ class TestHealNsViews(TestCase): self.client = Client() - model = '{"metadata": {"vnfdId": "1","vnfdName": "PGW001","vnfProvider": "zte","vnfdVersion": "V00001",' \ - '"vnfVersion": "V5.10.20","productType": "CN","vnfType": "PGW",' \ - '"description": "PGW VNFD description","isShared":true,"vnfExtendType":"driver"}}' + model = json.dumps({ + "metadata": { + "vnfdId": "1", + "vnfdName": "PGW001", + "vnfProvider": "zte", + "vnfdVersion": "V00001", + "vnfVersion": "V5.10.20", + "productType": "CN", + "vnfType": "PGW", + "description": "PGW VNFD description", + "isShared": True, + "vnfExtendType": "driver" + } + }) + NSInstModel.objects.filter().delete() + NfInstModel.objects.filter().delete() NSInstModel(id=self.ns_inst_id, name="ns_name", status='null').save() - NfInstModel.objects.create(nfinstid=self.nf_inst_id, nf_name='name_1', vnf_id='1', - vnfm_inst_id='1', ns_inst_id=self.ns_inst_id, - max_cpu='14', max_ram='12296', max_hd='101', max_shd="20", max_net=10, - status='null', mnfinstid=self.nf_uuid, package_id='pkg1', + NfInstModel.objects.create(nfinstid=self.nf_inst_id, + nf_name='name_1', + vnf_id='1', + vnfm_inst_id='1', + ns_inst_id=self.ns_inst_id, + max_cpu='14', + max_ram='12296', + max_hd='101', + max_shd="20", + max_net=10, + status='null', + mnfinstid=self.nf_uuid, + package_id='pkg1', vnfd_model=model) def tearDown(self): - NSInstModel.objects.filter().delete() - NfInstModel.objects.filter().delete() + pass @mock.patch.object(NSHealService, 'run') def test_heal_vnf_url(self, mock_run):