diff options
author | fujinhua <fu.jinhua@zte.com.cn> | 2019-04-11 09:56:16 +0800 |
---|---|---|
committer | fujinhua <fu.jinhua@zte.com.cn> | 2019-04-11 09:56:16 +0800 |
commit | 89fd50ca268ed9b9ed9904ad578c1416bb81f90d (patch) | |
tree | 4636e64faac04986d17d2ea61b265d6f0c4a4fd7 | |
parent | beae7e20ec71783a787c26a848699ecad4ac2915 (diff) |
Add ut test case to terminate vnf
Change-Id: If9f67d02ba75d7a7f1fb9c654d7de1f9a0b5de65
Issue-ID: VFC-1306
Signed-off-by: fujinhua <fu.jinhua@zte.com.cn>
-rw-r--r-- | lcm/lcm/nf/tests/test_terminate_vnf.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/lcm/lcm/nf/tests/test_terminate_vnf.py b/lcm/lcm/nf/tests/test_terminate_vnf.py index 59b7ead9..a64a7f3d 100644 --- a/lcm/lcm/nf/tests/test_terminate_vnf.py +++ b/lcm/lcm/nf/tests/test_terminate_vnf.py @@ -85,6 +85,7 @@ class TestNFTerminate(TestCase): NetworkInstModel.objects.all().delete()
SubNetworkInstModel.objects.all().delete()
PortInstModel.objects.all().delete()
+ NfInstModel.objects.all().delete()
def assert_job_result(self, job_id, job_progress, job_detail):
jobs = JobStatusModel.objects.filter(jobid=job_id,
@@ -112,6 +113,36 @@ class TestNFTerminate(TestCase): response = self.client.post("/api/vnflcm/v1/vnf_instances/12/terminate", data=req_data, format='json')
self.failUnlessEqual(status.HTTP_202_ACCEPTED, response.status_code, response.content)
+ @mock.patch.object(TerminateVnf, 'run')
+ def test_terminate_vnf_not_found(self, mock_run):
+ req_data = {
+ "terminationType": "GRACEFUL",
+ "gracefulTerminationTimeout": 120
+ }
+ mock_run.re.return_value = None
+ response = self.client.post("/api/vnflcm/v1/vnf_instances/567/terminate", data=req_data, format='json')
+ self.failUnlessEqual(status.HTTP_404_NOT_FOUND, response.status_code, response.content)
+
+ @mock.patch.object(TerminateVnf, 'run')
+ def test_terminate_vnf_conflict(self, mock_run):
+ req_data = {
+ "terminationType": "GRACEFUL",
+ "gracefulTerminationTimeout": 120
+ }
+ NfInstModel(nfinstid='123',
+ nf_name='VNF1',
+ nf_desc="VNF DESC",
+ vnfdid="1",
+ netype="XGW",
+ vendor="ZTE",
+ vnfSoftwareVersion="V1",
+ version="V1",
+ package_id="2",
+ status='NOT_INSTANTIATED').save()
+ mock_run.re.return_value = None
+ response = self.client.post("/api/vnflcm/v1/vnf_instances/123/terminate", data=req_data, format='json')
+ self.failUnlessEqual(status.HTTP_409_CONFLICT, response.status_code, response.content)
+
def test_terminate_vnf_when_inst_id_not_exist(self):
data = {
"terminationType": "GRACEFUL",
|