From: ying.yunlong Date: Mon, 8 Jan 2018 02:30:04 +0000 (+0800) Subject: Optimize vfc-vnflcm unit tests X-Git-Tag: v1.1.0~88 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F03%2F27603%2F1;p=vfc%2Fgvnfm%2Fvnflcm.git Optimize vfc-vnflcm unit tests Change-Id: Ia8875c665b4d7d221f99cff33087773b6a3b7020 Issue-ID: VFC-630 Signed-off-by: ying.yunlong --- diff --git a/lcm/lcm/nf/vnfs/const.py b/lcm/lcm/nf/vnfs/const.py index 6412e746..1a0cb672 100644 --- a/lcm/lcm/nf/vnfs/const.py +++ b/lcm/lcm/nf/vnfs/const.py @@ -91,275 +91,6 @@ inst_req_data = { } } - -# vnfd_rawdata -vnfd_rawdata = { - "rawData": { - "instance": { - "metadata": { - "designer": "sdno", - "name": "underlayervpn", - "csarVersion": "1.0", - "csarType": "SSAR", - "csarProvider": "huawei", - "version": "1.0", - "type": "SSAR", - "id": "ns_underlayervpn_1_0" - }, - "nodes": [ - { - "id": "ac2_fdhrbk3dvan8hl5wifm9lp1e9", - "type_name": "tosca.nodes.sdn.l3ac", - "template_name": "ac2", - "properties": { - "ip": { - "type_name": "string" - }, - "route": { - "type_name": "string" - }, - "port": { - "type_name": "string" - }, - "svlan": { - "type_name": "string" - } - }, - "interfaces": [ - { - "name": "Standard", - "type_name": "tosca.interfaces.node.lifecycle.Standard" - } - ], - "capabilities": [ - { - "name": "feature", - "type_name": "tosca.capabilities.Node" - }, - { - "name": "ac", - "type_name": "tosca.capabilities.sdn.ac" - } - ], - "relationships": [ - { - "target_node_id": "pe2_go3vo1ctxr1vlbl0ij8stbtj6", - "target_capability_name": "feature" - }, - { - "target_node_id": "ac2_fdhrbk3dvan8hl5wifm9lp1e9", - "target_capability_name": "feature" - } - ] - }, - { - "id": "ac1_jqows1ai0j0cmwk9jdvuknt97", - "type_name": "tosca.nodes.sdn.l3ac", - "template_name": "ac1", - "properties": { - "ip": { - "type_name": "string" - }, - "route": { - "type_name": "string" - }, - "port": { - "type_name": "string" - }, - "svlan": { - "type_name": "string" - } - }, - "interfaces": [ - { - "name": "Standard", - "type_name": "tosca.interfaces.node.lifecycle.Standard" - } - ], - "capabilities": [ - { - "name": "feature", - "type_name": "tosca.capabilities.Node" - }, - { - "name": "ac", - "type_name": "tosca.capabilities.sdn.ac" - } - ], - "relationships": [ - { - "target_node_id": "pe1_e58ekps6m45g6w9egs9lue2j7", - "target_capability_name": "feature" - }, - { - "target_node_id": "ac2_fdhrbk3dvan8hl5wifm9lp1e9", - "target_capability_name": "feature" - } - ] - }, - { - "id": "vpn_ie0xim076f7cje67fvrrq9tg1", - "type_name": "tosca.nodes.sdn.underlayVPN", - "template_name": "vpn", - "properties": { - "serviceType": { - "type_name": "string" - }, - "description": { - "type_name": "string" - }, - "name": { - "type_name": "string" - }, - "topology": { - "type_name": "string" - } - }, - "interfaces": [ - { - "name": "Standard", - "type_name": "tosca.interfaces.node.lifecycle.Standard" - } - ], - "capabilities": [ - { - "name": "feature", - "type_name": "tosca.capabilities.Node" - } - ], - "relationships": [ - { - "target_node_id": "ac1_jqows1ai0j0cmwk9jdvuknt97", - "target_capability_name": "feature" - }, - { - "target_node_id": "ac2_fdhrbk3dvan8hl5wifm9lp1e9", - "target_capability_name": "feature" - } - ] - }, - { - "id": "pe1_e58ekps6m45g6w9egs9lue2j7", - "type_name": "tosca.nodes.sdn.l3pe", - "template_name": "pe1", - "properties": { - "id": { - "type_name": "string" - } - }, - "interfaces": [ - { - "name": "Standard", - "type_name": "tosca.interfaces.node.lifecycle.Standard" - } - ], - "capabilities": [ - { - "name": "feature", - "type_name": "tosca.capabilities.Node" - }, - { - "name": "pe", - "type_name": "tosca.capabilities.sdn.pe" - } - ] - }, - { - "id": "pe2_go3vo1ctxr1vlbl0ij8stbtj6", - "type_name": "tosca.nodes.sdn.l3pe", - "template_name": "pe2", - "properties": { - "id": { - "type_name": "string" - } - }, - "interfaces": [ - { - "name": "Standard", - "type_name": "tosca.interfaces.node.lifecycle.Standard" - } - ], - "capabilities": [ - { - "name": "feature", - "type_name": "tosca.capabilities.Node" - }, - { - "name": "pe", - "type_name": "tosca.capabilities.sdn.pe" - } - ] - } - ], - "substitution": { - "node_type_name": "tosca.nodes.sdn.ext.NS.ns_underlayervpn" - }, - "inputs": { - "ac2_ip": { - "type_name": "string", - "description": "ac2_ipofunderlayvpn" - }, - "ac2_route": { - "type_name": "string", - "description": "ac2_routeofunderlayvpn" - }, - "serviceType": { - "type_name": "string", - "description": "serviceTypeofunderlayvpn" - }, - "description": { - "type_name": "string", - "description": "descriptionofunderlayvpn" - }, - "pe2_id": { - "type_name": "string", - "description": "pe2_idofunderlayvpn" - }, - "ac1_route": { - "type_name": "string", - "description": "ac1_routeofunderlayvpn" - }, - "ac1_svlan": { - "type_name": "integer", - "description": "ac1_svlanofunderlayvpn" - }, - "name": { - "type_name": "string", - "description": "Nameofunderlayervpn" - }, - "ac1_ip": { - "type_name": "string", - "description": "ac1_ipofunderlayvpn" - }, - "ac2_port": { - "type_name": "string", - "description": "ac2_portofunderlayvpn" - }, - "pe1_id": { - "type_name": "string", - "description": "pe1_idofunderlayvpn" - }, - "technology": { - "type_name": "string", - "description": "technologyofunderlayvpn" - }, - "ac1_port": { - "type_name": "string", - "description": "ac1_portofunderlayvpn" - }, - "ac2_svlan": { - "type_name": "integer", - "description": "ac2_svlanofunderlayvpn" - }, - "topology": { - "type_name": "string", - "description": "topologyofunderlayvpn" - } - } - } - } -} - # vnfd_model_dict vnfd_model_dict = { 'metadata': { @@ -923,3 +654,271 @@ vnfpackage_info = { "id": "ns_underlayervpn_1_0" } } + +# # vnfd_rawdata +# vnfd_rawdata = { +# "rawData": { +# "instance": { +# "metadata": { +# "designer": "sdno", +# "name": "underlayervpn", +# "csarVersion": "1.0", +# "csarType": "SSAR", +# "csarProvider": "huawei", +# "version": "1.0", +# "type": "SSAR", +# "id": "ns_underlayervpn_1_0" +# }, +# "nodes": [ +# { +# "id": "ac2_fdhrbk3dvan8hl5wifm9lp1e9", +# "type_name": "tosca.nodes.sdn.l3ac", +# "template_name": "ac2", +# "properties": { +# "ip": { +# "type_name": "string" +# }, +# "route": { +# "type_name": "string" +# }, +# "port": { +# "type_name": "string" +# }, +# "svlan": { +# "type_name": "string" +# } +# }, +# "interfaces": [ +# { +# "name": "Standard", +# "type_name": "tosca.interfaces.node.lifecycle.Standard" +# } +# ], +# "capabilities": [ +# { +# "name": "feature", +# "type_name": "tosca.capabilities.Node" +# }, +# { +# "name": "ac", +# "type_name": "tosca.capabilities.sdn.ac" +# } +# ], +# "relationships": [ +# { +# "target_node_id": "pe2_go3vo1ctxr1vlbl0ij8stbtj6", +# "target_capability_name": "feature" +# }, +# { +# "target_node_id": "ac2_fdhrbk3dvan8hl5wifm9lp1e9", +# "target_capability_name": "feature" +# } +# ] +# }, +# { +# "id": "ac1_jqows1ai0j0cmwk9jdvuknt97", +# "type_name": "tosca.nodes.sdn.l3ac", +# "template_name": "ac1", +# "properties": { +# "ip": { +# "type_name": "string" +# }, +# "route": { +# "type_name": "string" +# }, +# "port": { +# "type_name": "string" +# }, +# "svlan": { +# "type_name": "string" +# } +# }, +# "interfaces": [ +# { +# "name": "Standard", +# "type_name": "tosca.interfaces.node.lifecycle.Standard" +# } +# ], +# "capabilities": [ +# { +# "name": "feature", +# "type_name": "tosca.capabilities.Node" +# }, +# { +# "name": "ac", +# "type_name": "tosca.capabilities.sdn.ac" +# } +# ], +# "relationships": [ +# { +# "target_node_id": "pe1_e58ekps6m45g6w9egs9lue2j7", +# "target_capability_name": "feature" +# }, +# { +# "target_node_id": "ac2_fdhrbk3dvan8hl5wifm9lp1e9", +# "target_capability_name": "feature" +# } +# ] +# }, +# { +# "id": "vpn_ie0xim076f7cje67fvrrq9tg1", +# "type_name": "tosca.nodes.sdn.underlayVPN", +# "template_name": "vpn", +# "properties": { +# "serviceType": { +# "type_name": "string" +# }, +# "description": { +# "type_name": "string" +# }, +# "name": { +# "type_name": "string" +# }, +# "topology": { +# "type_name": "string" +# } +# }, +# "interfaces": [ +# { +# "name": "Standard", +# "type_name": "tosca.interfaces.node.lifecycle.Standard" +# } +# ], +# "capabilities": [ +# { +# "name": "feature", +# "type_name": "tosca.capabilities.Node" +# } +# ], +# "relationships": [ +# { +# "target_node_id": "ac1_jqows1ai0j0cmwk9jdvuknt97", +# "target_capability_name": "feature" +# }, +# { +# "target_node_id": "ac2_fdhrbk3dvan8hl5wifm9lp1e9", +# "target_capability_name": "feature" +# } +# ] +# }, +# { +# "id": "pe1_e58ekps6m45g6w9egs9lue2j7", +# "type_name": "tosca.nodes.sdn.l3pe", +# "template_name": "pe1", +# "properties": { +# "id": { +# "type_name": "string" +# } +# }, +# "interfaces": [ +# { +# "name": "Standard", +# "type_name": "tosca.interfaces.node.lifecycle.Standard" +# } +# ], +# "capabilities": [ +# { +# "name": "feature", +# "type_name": "tosca.capabilities.Node" +# }, +# { +# "name": "pe", +# "type_name": "tosca.capabilities.sdn.pe" +# } +# ] +# }, +# { +# "id": "pe2_go3vo1ctxr1vlbl0ij8stbtj6", +# "type_name": "tosca.nodes.sdn.l3pe", +# "template_name": "pe2", +# "properties": { +# "id": { +# "type_name": "string" +# } +# }, +# "interfaces": [ +# { +# "name": "Standard", +# "type_name": "tosca.interfaces.node.lifecycle.Standard" +# } +# ], +# "capabilities": [ +# { +# "name": "feature", +# "type_name": "tosca.capabilities.Node" +# }, +# { +# "name": "pe", +# "type_name": "tosca.capabilities.sdn.pe" +# } +# ] +# } +# ], +# "substitution": { +# "node_type_name": "tosca.nodes.sdn.ext.NS.ns_underlayervpn" +# }, +# "inputs": { +# "ac2_ip": { +# "type_name": "string", +# "description": "ac2_ipofunderlayvpn" +# }, +# "ac2_route": { +# "type_name": "string", +# "description": "ac2_routeofunderlayvpn" +# }, +# "serviceType": { +# "type_name": "string", +# "description": "serviceTypeofunderlayvpn" +# }, +# "description": { +# "type_name": "string", +# "description": "descriptionofunderlayvpn" +# }, +# "pe2_id": { +# "type_name": "string", +# "description": "pe2_idofunderlayvpn" +# }, +# "ac1_route": { +# "type_name": "string", +# "description": "ac1_routeofunderlayvpn" +# }, +# "ac1_svlan": { +# "type_name": "integer", +# "description": "ac1_svlanofunderlayvpn" +# }, +# "name": { +# "type_name": "string", +# "description": "Nameofunderlayervpn" +# }, +# "ac1_ip": { +# "type_name": "string", +# "description": "ac1_ipofunderlayvpn" +# }, +# "ac2_port": { +# "type_name": "string", +# "description": "ac2_portofunderlayvpn" +# }, +# "pe1_id": { +# "type_name": "string", +# "description": "pe1_idofunderlayvpn" +# }, +# "technology": { +# "type_name": "string", +# "description": "technologyofunderlayvpn" +# }, +# "ac1_port": { +# "type_name": "string", +# "description": "ac1_portofunderlayvpn" +# }, +# "ac2_svlan": { +# "type_name": "integer", +# "description": "ac2_svlanofunderlayvpn" +# }, +# "topology": { +# "type_name": "string", +# "description": "topologyofunderlayvpn" +# } +# } +# } +# } +# } diff --git a/lcm/lcm/nf/vnfs/tests/test_vnf_cancel.py b/lcm/lcm/nf/vnfs/tests/test_vnf_cancel.py index 038cbcf1..228e9b1b 100644 --- a/lcm/lcm/nf/vnfs/tests/test_vnf_cancel.py +++ b/lcm/lcm/nf/vnfs/tests/test_vnf_cancel.py @@ -94,8 +94,7 @@ class TestNFTerminate(TestCase): descp=job_detail) self.assertEqual(1, len(jobs)) - @mock.patch.object(restcall, 'call_req') - def test_delete_vnf_identifier(self, mock_call_req): + def test_delete_vnf_identifier(self): NfInstModel.objects.create(nfinstid='1111', nf_name='2222', package_id='todo', @@ -110,17 +109,6 @@ class TestNFTerminate(TestCase): vnfConfigurableProperties='todo', localizationLanguage='EN_US', create_time=now_time()) - vnf_info = { - "vnf-id": "vnf-id-test111", - "vnf-name": "vnf-name-test111", - "vnf-type": "vnf-type-test111", - "in-maint": True, - "is-closed-loop-disabled": False, - "resource-version": "1505465356262" - } - r1_query_vnf_to_aai = [0, json.JSONEncoder().encode(vnf_info), '200'] - r1_delete_vnf_to_aai = [0, json.JSONEncoder().encode({}), '200'] - mock_call_req.side_effect = [r1_query_vnf_to_aai, r1_delete_vnf_to_aai] response = self.client.delete("/api/vnflcm/v1/vnf_instances/1111") self.failUnlessEqual(status.HTTP_204_NO_CONTENT, response.status_code) self.assertEqual(None, response.data) diff --git a/lcm/lcm/nf/vnfs/tests/test_vnf_create.py b/lcm/lcm/nf/vnfs/tests/test_vnf_create.py index 7804e109..6613706b 100644 --- a/lcm/lcm/nf/vnfs/tests/test_vnf_create.py +++ b/lcm/lcm/nf/vnfs/tests/test_vnf_create.py @@ -19,7 +19,7 @@ import mock from django.test import TestCase, Client from rest_framework import status -from lcm.nf.vnfs.const import vnfd_rawdata, c1_data_get_tenant_id, c4_data_create_network, c2_data_create_volume, \ +from lcm.nf.vnfs.const import c1_data_get_tenant_id, c4_data_create_network, c2_data_create_volume, \ c5_data_create_subnet, c3_data_get_volume, c6_data_create_port, c7_data_create_flavor, c8_data_list_image, \ c9_data_create_vm, c10_data_get_vm, inst_req_data, vnfpackage_info from lcm.nf.vnfs.vnf_create.inst_vnf import InstVnf @@ -45,19 +45,8 @@ class TestNFInstantiate(TestCase): @mock.patch.object(restcall, 'call_req') def test_create_vnf_identifier(self, mock_call_req): - r1_get_csarid_by_vnfdid = [0, json.JSONEncoder().encode( - { - 'csars': [ - { - 'package_id': '222', - 'csarId': '2222', - 'vnfdId': '111' - } - ] - }), '200'] - r2_get_rawdata_from_catalog = [0, json.JSONEncoder().encode(vnfd_rawdata), '200'] - r3_create_vnf_to_aai = [0, json.JSONEncoder().encode({}), '200'] - mock_call_req.side_effect = [r1_get_csarid_by_vnfdid, r2_get_rawdata_from_catalog, r3_create_vnf_to_aai] + r2_get_vnfpackage_from_catalog = [0, json.JSONEncoder().encode(vnfpackage_info), '200'] + mock_call_req.side_effect = [r2_get_vnfpackage_from_catalog] data = { "vnfdId": "111", "vnfInstanceName": "vFW_01",