1 # Copyright 2017 ZTE Corporation.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
16 from django.test import TestCase, Client
17 from rest_framework import status
19 from lcm.pub.database.models import NfInstModel, JobStatusModel, VmInstModel, NetworkInstModel, SubNetworkInstModel, \
20 PortInstModel, FlavourInstModel, StorageInstModel, NfvoRegInfoModel
21 from lcm.pub.utils.timeutil import now_time
24 class TestNFTerminate(TestCase):
26 self.client = Client()
27 StorageInstModel.objects.create(storageid="1",
33 NetworkInstModel.objects.create(networkid='1',
41 SubNetworkInstModel.objects.create(subnetworkid='1',
50 PortInstModel.objects.create(portid='1',
60 FlavourInstModel.objects.create(flavourid="1",
65 VmInstModel.objects.create(vmid="1",
73 NfvoRegInfoModel.objects.create(nfvoid='1111',
78 VmInstModel.objects.all().delete()
79 NetworkInstModel.objects.all().delete()
80 SubNetworkInstModel.objects.all().delete()
81 PortInstModel.objects.all().delete()
83 def assert_job_result(self, job_id, job_progress, job_detail):
84 jobs = JobStatusModel.objects.filter(jobid=job_id,
85 progress=job_progress,
87 self.assertEqual(1, len(jobs))
89 def test_delete_vnf_identifier(self):
90 NfInstModel.objects.create(nfinstid='1111',
97 status='NOT_INSTANTIATED',
100 vnfSoftwareVersion='',
101 vnfConfigurableProperties='todo',
102 localizationLanguage='EN_US',
103 create_time=now_time())
104 response = self.client.delete("/api/vnflcm/v1/vnf_instances/1111")
105 self.failUnlessEqual(status.HTTP_204_NO_CONTENT, response.status_code)
106 self.assertEqual(None, response.data)
108 def test_delete_vnf_identifier_when_vnf_not_exist(self):
109 response = self.client.delete("/api/vnflcm/v1/vnf_instances/1111")
110 self.failUnlessEqual(status.HTTP_204_NO_CONTENT, response.status_code)