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.
17 from django.test import Client
18 from rest_framework import status
21 class VnfGrantViewTest(unittest.TestCase):
23 self.client = Client()
28 def test_grant_vnf_normal(self):
34 "operation": "INSTANTIATE",
35 "isAutomaticInvocation": True,
36 "instantiationLevelId": "5",
42 "resourceTemplateId": "3",
44 "vimConnectionId": "4",
45 "resourceProviderId": "5",
47 "vimLevelResourceType": "7"
51 "placementConstraints": [
53 "affinityOrAntiAffinity": "AFFINITY",
59 "vimConnectionId": "2",
60 "resourceProviderId": "3"
67 "sameResourceGroup": True,
72 "vimConnectionId": "2",
73 "resourceProviderId": "3"
78 "additionalParams": {},
88 response = self.client.post("/api/nslcm/v2/grants", data=data, format='json')
89 self.assertEqual(status.HTTP_201_CREATED, response.status_code, response.content)
90 resp_data = json.loads(response.content)
92 "id": resp_data.get("id"),
96 self.assertEqual(expect_resp_data, resp_data)
98 def test_get_notify_vnf_normal(self):
99 response = self.client.get("/api/nslcm/v2/ns/1/vnfs/1/Notify")
100 self.assertEqual(status.HTTP_204_NO_CONTENT, response.status_code, response.content)