diff options
author | ying.yunlong <ying.yunlong@zte.com.cn> | 2018-01-09 15:12:19 +0800 |
---|---|---|
committer | ying.yunlong <ying.yunlong@zte.com.cn> | 2018-01-09 15:12:19 +0800 |
commit | c4390ea3f4fc000058e3a1d24e38a4143671ba97 (patch) | |
tree | 72d9f5a79405dabfabbc620ba1b3d0e4285d5132 | |
parent | f18464b1f38ff751a7c12447fb8cf8d8c7b0c473 (diff) |
Add vfc-vnflcm create vnf unitest
Change-Id: I2125bb9fa18fbc2b95c1610fe4be6f3fcb4476a1
Issue-ID: VFC-630
Signed-off-by: ying.yunlong <ying.yunlong@zte.com.cn>
-rw-r--r-- | lcm/lcm/nf/vnfs/tests/test_vnf_create.py | 22 | ||||
-rw-r--r-- | lcm/lcm/nf/vnfs/vnf_create/create_vnf_identifier.py | 1 |
2 files changed, 23 insertions, 0 deletions
diff --git a/lcm/lcm/nf/vnfs/tests/test_vnf_create.py b/lcm/lcm/nf/vnfs/tests/test_vnf_create.py index 3d3e9ad1..7965072d 100644 --- a/lcm/lcm/nf/vnfs/tests/test_vnf_create.py +++ b/lcm/lcm/nf/vnfs/tests/test_vnf_create.py @@ -51,6 +51,28 @@ class TestNFInstantiate(TestCase): descp=job_detail) self.assertEqual(1, len(jobs)) + def test_create_vnf_identifier_when_vnf_is_exist(self): + 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()) + data = { + "vnfdId": "111", + "vnfInstanceName": "vFW_01", + "vnfInstanceDescription": "vFW in Nanjing TIC Edge" + } + response = self.client.post("/api/vnflcm/v1/vnf_instances", data=data, format='json') + self.failUnlessEqual(status.HTTP_500_INTERNAL_SERVER_ERROR, response.status_code) + context = json.loads(response.content) + self.assertEqual({'error': 'VNF is already exist.'}, context) + @mock.patch.object(restcall, 'call_req') def test_create_vnf_identifier(self, mock_call_req): r2_get_vnfpackage_from_catalog = [0, json.JSONEncoder().encode(vnfpackage_info), '200'] diff --git a/lcm/lcm/nf/vnfs/vnf_create/create_vnf_identifier.py b/lcm/lcm/nf/vnfs/vnf_create/create_vnf_identifier.py index 9d6e2cdf..593248dd 100644 --- a/lcm/lcm/nf/vnfs/vnf_create/create_vnf_identifier.py +++ b/lcm/lcm/nf/vnfs/vnf_create/create_vnf_identifier.py @@ -40,6 +40,7 @@ class CreateVnf: self.save_db() except NFLCMException as e: logger.debug('Create VNF instance[%s]: %s', self.nf_inst_id, e.message) + raise NFLCMException(e.message) except: NfInstModel.objects.create(nfinstid=self.nf_inst_id, nf_name=self.vnf_instance_mame, |