diff options
author | fujinhua <fu.jinhua@zte.com.cn> | 2019-04-11 10:46:24 +0800 |
---|---|---|
committer | fujinhua <fu.jinhua@zte.com.cn> | 2019-04-11 10:46:24 +0800 |
commit | 9f562b86973f080d392d10db2655b80d74826a4e (patch) | |
tree | 1b982c4097aefc320daab99f0a61ad883c27848b /lcm | |
parent | b10195f3df9535641c6a142dfededf770b201ad0 (diff) |
Add ut cases for inst vnf
Change-Id: Ibacaba414033d335e96af03242963d9ee6b10ac6
Issue-ID: VFC-1306
Signed-off-by: fujinhua <fu.jinhua@zte.com.cn>
Diffstat (limited to 'lcm')
-rw-r--r-- | lcm/lcm/nf/tests/test_instantiate_vnf.py | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/lcm/lcm/nf/tests/test_instantiate_vnf.py b/lcm/lcm/nf/tests/test_instantiate_vnf.py index d52787b9..03137054 100644 --- a/lcm/lcm/nf/tests/test_instantiate_vnf.py +++ b/lcm/lcm/nf/tests/test_instantiate_vnf.py @@ -59,7 +59,7 @@ class TestNFInstantiate(TestCase): }
def tearDown(self):
- pass
+ NfInstModel.objects.all().delete()
def assert_job_result(self, job_id, job_progress, job_detail):
jobs = JobStatusModel.objects.filter(jobid=job_id,
@@ -69,11 +69,44 @@ class TestNFInstantiate(TestCase): @mock.patch.object(InstantiateVnf, 'run')
def test_instantiate_vnf(self, mock_run):
- NfInstModel(nfinstid='12', nf_name='VNF1', status='UN_INSTANTIATED').save()
+ NfInstModel(
+ nfinstid='12',
+ nf_name='VNF1',
+ status='NOT_INSTANTIATED'
+ ).save()
mock_run.re.return_value = None
- response = self.client.post('/api/vnflcm/v1/vnf_instances/12/instantiate', data=inst_req_data, format='json')
+ response = self.client.post(
+ '/api/vnflcm/v1/vnf_instances/12/instantiate',
+ data=inst_req_data,
+ format='json'
+ )
self.failUnlessEqual(status.HTTP_202_ACCEPTED, response.status_code)
+ @mock.patch.object(InstantiateVnf, 'run')
+ def test_instantiate_vnf_notfound(self, mock_run):
+ mock_run.re.return_value = None
+ response = self.client.post(
+ '/api/vnflcm/v1/vnf_instances/3421/instantiate',
+ data=inst_req_data,
+ format='json'
+ )
+ self.failUnlessEqual(status.HTTP_404_NOT_FOUND, response.status_code, response.content)
+
+ @mock.patch.object(InstantiateVnf, 'run')
+ def test_instantiate_vnf_conflict(self, mock_run):
+ NfInstModel(
+ nfinstid='1123',
+ nf_name='VNF1',
+ status='INSTANTIATED'
+ ).save()
+ mock_run.re.return_value = None
+ response = self.client.post(
+ '/api/vnflcm/v1/vnf_instances/1123/instantiate',
+ data=inst_req_data,
+ format='json'
+ )
+ self.failUnlessEqual(status.HTTP_409_CONFLICT, response.status_code, response.content)
+
def test_instantiate_vnf_when_inst_id_not_exist(self):
self.nf_inst_id = str(uuid.uuid4())
self.job_id = JobUtil.create_job('NF', 'CREATE', self.nf_inst_id)
|