1 # Copyright 2018 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
18 from lcm.ns_pnfs.biz.delete_pnf import DeletePnf
19 from lcm.pub.database.models import PNFInstModel
22 class TestDeletePnfViews(TestCase):
24 self.client = Client()
29 def test_do_biz(self):
30 pnfId = str(uuid.uuid4())
31 PNFInstModel(pnfId=pnfId,
33 pnfdId=str(uuid.uuid4()),
34 pnfdInfoId=str(uuid.uuid4()),
35 pnfProfileId=str(uuid.uuid4()),
37 "cpInstanceId": str(uuid.uuid4()),
38 "cpdId": "pnf_ext_cp01",
41 DeletePnf(pnfId).do_biz()
42 pnfInst = PNFInstModel.objects.filter(pnfId=pnfId)
43 self.assertEqual(0, len(pnfInst))
45 def test_rest_api(self):
46 pnfId = str(uuid.uuid4())
47 PNFInstModel(pnfId=pnfId,
49 pnfdId=str(uuid.uuid4()),
50 pnfdInfoId=str(uuid.uuid4()),
51 pnfProfileId=str(uuid.uuid4()),
53 "cpInstanceId": str(uuid.uuid4()),
54 "cpdId": "pnf_ext_cp01",
57 response = self.client.delete("/api/nslcm/v1/pnfs/%s" % pnfId)
58 self.assertEqual(status.HTTP_204_NO_CONTENT, response.status_code)