summaryrefslogtreecommitdiffstats
path: root/lcm
diff options
context:
space:
mode:
Diffstat (limited to 'lcm')
-rw-r--r--lcm/lcm/nf/vnfs/tests/test_vnf_cancel.py11
-rw-r--r--lcm/lcm/nf/vnfs/tests/test_vnf_create.py39
2 files changed, 27 insertions, 23 deletions
diff --git a/lcm/lcm/nf/vnfs/tests/test_vnf_cancel.py b/lcm/lcm/nf/vnfs/tests/test_vnf_cancel.py
index f7732181..4cde4436 100644
--- a/lcm/lcm/nf/vnfs/tests/test_vnf_cancel.py
+++ b/lcm/lcm/nf/vnfs/tests/test_vnf_cancel.py
@@ -20,7 +20,7 @@ from rest_framework import status
from lcm.nf.vnfs.vnf_cancel.term_vnf import TermVnf
from lcm.pub.database.models import NfInstModel, JobStatusModel, VmInstModel, NetworkInstModel, SubNetworkInstModel, \
- PortInstModel, FlavourInstModel, StorageInstModel
+ PortInstModel, FlavourInstModel, StorageInstModel, NfvoRegInfoModel
from lcm.pub.utils import restcall
from lcm.pub.utils.jobutil import JobUtil
from lcm.pub.utils.timeutil import now_time
@@ -41,6 +41,7 @@ class TestNFTerminate(TestCase):
FlavourInstModel.objects.create(flavourid="1", vimid="1", resouceid="11", instid="1111", is_predefined=1)
VmInstModel.objects.create(vmid="1", vimid="1", resouceid="11", insttype=0, instid="1111", vmname="test_01",
is_predefined=1, operationalstate=1)
+ NfvoRegInfoModel.objects.create(nfvoid='1111', vnfminstid='11111', apiurl='1')
def tearDown(self):
VmInstModel.objects.all().delete()
@@ -54,7 +55,7 @@ class TestNFTerminate(TestCase):
progress=job_progress,
descp=job_detail)
self.assertEqual(1, len(jobs))
- """
+
def test_delete_vnf_identifier(self):
NfInstModel.objects.create(nfinstid='1111', nf_name='2222', package_id='todo', version='', vendor='',
netype='', vnfd_model='', status='NOT_INSTANTIATED', nf_desc='', vnfdid='',
@@ -64,6 +65,7 @@ class TestNFTerminate(TestCase):
self.failUnlessEqual(status.HTTP_204_NO_CONTENT, response.status_code)
self.assertEqual(None, response.data)
+ """
def test_delete_vnf_identifier_when_vnf_not_exist(self):
response = self.client.delete("/openoapi/vnflcm/v1/vnf_instances/1111")
self.failUnlessEqual(status.HTTP_500_INTERNAL_SERVER_ERROR, response.status_code)
@@ -77,6 +79,7 @@ class TestNFTerminate(TestCase):
response = self.client.delete("/openoapi/vnflcm/v1/vnf_instances/1111")
self.failUnlessEqual(status.HTTP_500_INTERNAL_SERVER_ERROR, response.status_code)
self.assertEqual("Don't allow to delete vnf(status:[VNF_INSTANTIATED])", response.data["error"])
+ """
@mock.patch.object(TermVnf, 'run')
def test_terminate_vnf(self, mock_run):
@@ -84,6 +87,7 @@ class TestNFTerminate(TestCase):
response = self.client.post("/openoapi/vnflcm/v1/vnf_instances/12/terminate", data={}, format='json')
self.failUnlessEqual(status.HTTP_202_ACCEPTED, response.status_code)
+ """
def test_terminate_vnf_when_inst_id_not_exist(self):
data = {"terminationType": "GRACEFUL",
"gracefulTerminationTimeout": 120}
@@ -92,6 +96,7 @@ class TestNFTerminate(TestCase):
JobUtil.add_job_status(self.job_id, 0, "INST_VNF_READY")
TermVnf(data, nf_inst_id=self.nf_inst_id, job_id=self.job_id).run()
self.assert_job_result(self.job_id, 255, "VnfInst(%s) does not exist" % self.nf_inst_id)
+ """
@mock.patch.object(restcall, 'call_req')
@mock.patch.object(api, 'call')
@@ -112,4 +117,4 @@ class TestNFTerminate(TestCase):
JobUtil.add_job_status(self.job_id, 0, "INST_VNF_READY")
TermVnf(data, nf_inst_id=self.nf_inst_id, job_id=self.job_id).run()
self.assert_job_result(self.job_id, 100, "Terminate Vnf success.")
- """
+
diff --git a/lcm/lcm/nf/vnfs/tests/test_vnf_create.py b/lcm/lcm/nf/vnfs/tests/test_vnf_create.py
index 96bb2282..4f248ac7 100644
--- a/lcm/lcm/nf/vnfs/tests/test_vnf_create.py
+++ b/lcm/lcm/nf/vnfs/tests/test_vnf_create.py
@@ -46,12 +46,12 @@ class TestNFInstantiate(TestCase):
def test_swagger_ok(self):
response = self.client.get("/openoapi/vnflcm/v1/swagger.json", format='json')
self.assertEqual(response.status_code, status.HTTP_200_OK)
-'''
+
@mock.patch.object(restcall, 'call_req')
def test_create_vnf_identifier(self, mock_call_req):
- r1_get_csarid_by_vnfdid = [0, json.JSONEncoder().encode([{'package_id': '222',
+ r1_get_csarid_by_vnfdid = [0, json.JSONEncoder().encode({'csars':[{'package_id': '222',
'csarId': '2222',
- 'vnfdId': '111'}]), '200']
+ 'vnfdId': '111'}]}), '200']
r2_get_rawdata_from_catalog = [0, json.JSONEncoder().encode(vnfd_rawdata), '200']
mock_call_req.side_effect = [r1_get_csarid_by_vnfdid, r2_get_rawdata_from_catalog]
data = {
@@ -87,9 +87,9 @@ class TestNFInstantiate(TestCase):
NfInstModel.objects.create(nfinstid='1111', nf_name='vFW_01', package_id='222',
version='', vendor='', netype='', vnfd_model='', status='NOT_INSTANTIATED',
nf_desc='vFW in Nanjing TIC Edge', vnfdid='111', create_time=now_time())
- r1_get_csarid_by_vnfdid = [1, json.JSONEncoder().encode([{'package_id': '222',
- 'csar_id': '2222',
- 'vnfd_id': '111'}]), '200']
+ r1_get_csarid_by_vnfdid = [1, json.JSONEncoder().encode({'csars':[{'package_id': '222',
+ 'csarId': '2222',
+ 'vnfdId': '111'}]}), '200']
mock_call_req.side_effect = [r1_get_csarid_by_vnfdid]
self.nf_inst_id = '1111'
self.job_id = JobUtil.create_job('NF', 'CREATE', self.nf_inst_id)
@@ -103,9 +103,9 @@ class TestNFInstantiate(TestCase):
NfInstModel.objects.create(nfinstid='1111', nf_name='vFW_01', package_id='222',
version='', vendor='', netype='', vnfd_model='', status='NOT_INSTANTIATED',
nf_desc='vFW in Nanjing TIC Edge', vnfdid='111', create_time=now_time())
- r1_get_csarid_by_vnfdid = [0, json.JSONEncoder().encode([{'package_id': '222',
- 'csar_id': '2222',
- 'vnfd_id': '111'}]), '200']
+ r1_get_csarid_by_vnfdid = [0, json.JSONEncoder().encode({'csars':[{'package_id': '222',
+ 'csarId': '2222',
+ 'vnfdId': '111'}]}), '200']
r2_get_rawdata_from_catalog = [1, json.JSONEncoder().encode(vnfd_rawdata), '200']
mock_call_req.side_effect = [r1_get_csarid_by_vnfdid, r2_get_rawdata_from_catalog]
self.nf_inst_id = '1111'
@@ -120,9 +120,9 @@ class TestNFInstantiate(TestCase):
NfInstModel.objects.create(nfinstid='1111', nf_name='vFW_01', package_id='222',
version='', vendor='', netype='', vnfd_model='', status='NOT_INSTANTIATED',
nf_desc='vFW in Nanjing TIC Edge', vnfdid='111', create_time=now_time())
- r1_get_csarid_by_vnfdid = [0, json.JSONEncoder().encode([{'package_id': '222',
- 'csar_id': '2222',
- 'vnfd_id': '111'}]), '200']
+ 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_apply_grant_result = [1, json.JSONEncoder().encode(
{"vim": {"vimid": 'vimid_1', "accessinfo": {"tenant": 'tenantname_1'}}}), '200']
@@ -136,13 +136,13 @@ class TestNFInstantiate(TestCase):
@mock.patch.object(restcall, 'call_req')
@mock.patch.object(api, 'call')
- def test_instantiate_vnf_when_(self, mock_call, mock_call_req):
+ def test_instantiate_vnf_when_unexpected_exception(self, mock_call, mock_call_req):
NfInstModel.objects.create(nfinstid='1111', nf_name='vFW_01', package_id='222',
version='', vendor='', netype='', vnfd_model='', status='NOT_INSTANTIATED',
nf_desc='vFW in Nanjing TIC Edge', vnfdid='111', create_time=now_time())
- r1_get_csarid_by_vnfdid = [0, json.JSONEncoder().encode([{'package_id': '222',
- 'csar_id': '2222',
- 'vnfd_id': '111'}]), '200']
+ 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_apply_grant_result = [0, json.JSONEncoder().encode(
{"vim": {"vimid": 'vimid_1', "accessinfo": {"tenant": 'tenantname_1'}}}), '200']
@@ -161,9 +161,9 @@ class TestNFInstantiate(TestCase):
NfInstModel.objects.create(nfinstid='1111', nf_name='vFW_01', package_id='222',
version='', vendor='', netype='', vnfd_model='', status='NOT_INSTANTIATED',
nf_desc='vFW in Nanjing TIC Edge', vnfdid='111', create_time=now_time())
- r1_get_csarid_by_vnfdid = [0, json.JSONEncoder().encode([{'package_id': '222',
- 'csar_id': '2222',
- 'vnfd_id': '111'}]), '200']
+ 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_apply_grant_result = [0, json.JSONEncoder().encode(
{"vim": {"vimid": 'vimid_1', "accessinfo": {"tenant": 'tenantname_1'}}}), '200']
@@ -179,4 +179,3 @@ class TestNFInstantiate(TestCase):
data = inst_req_data
InstVnf(data, nf_inst_id=self.nf_inst_id, job_id=self.job_id).run()
self.assert_job_result(self.job_id, 100, "Instantiate Vnf success.")
-''' \ No newline at end of file