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)
102 def test_notify_vnf_normal(self):
105 "notificationType": "string",
106 "subscriptionId": "string",
107 "timeStamp": "string",
108 "notificationStatus": "START",
109 "operationState": "STARTING",
110 "vnfInstanceId": "string",
111 "operation": "INSTANTIATE",
112 "isAutomaticInvocation": True,
113 "vnfLcmOpOccId": "string",
115 "vnfcInstanceId": "string",
117 "changeType": "added",
122 "affectedVirtualLinks": [{
123 "vlInstanceId": "string",
125 "changeType": "added",
127 "resourceType": "network",
128 "resourceId": "string",
129 "resourceName": "string"
132 "affectedVirtualStorages": [{}],
134 "vnfInstanceName": "string",
135 "vnfInstanceDescription": "string",
136 "vnfConfigurableProperties": {
137 "additionalProp1": "string",
138 "additionalProp2": "string",
139 "additionalProp3": "string"
142 "additionalProp1": "string",
143 "additionalProp2": "string",
144 "additionalProp3": "string"
147 "additionalProp1": "string",
148 "additionalProp2": "string",
149 "additionalProp3": "string"
151 "vimConnectionInfo": [{
156 "additionalProp1": "string",
157 "additionalProp2": "string",
158 "additionalProp3": "string"
161 "additionalProp1": "string",
162 "additionalProp2": "string",
163 "additionalProp3": "string"
166 "additionalProp1": "string",
167 "additionalProp2": "string",
168 "additionalProp3": "string"
171 "vnfPkgId": "string",
173 "vnfProvider": "string",
174 "vnfProductName": "string",
175 "vnfSoftwareVersion": "string",
176 "vnfdVersion": "string"
178 "changedExtConnectivity": [{
181 "vimConnectionId": "string",
182 "resourceProviderId": "string",
183 "resourceId": "string",
184 "vimLevelResourceType": "string"
189 "vimConnectionId": "string",
190 "resourceProviderId": "string",
191 "resourceId": "string",
192 "vimLevelResourceType": "string"
194 "cpInstanceId": "string"
216 response = self.client.post("/api/nslcm/v2/ns/1/vnfs/2/Notify", data=data, format='json')
217 self.assertEqual(status.HTTP_204_NO_CONTENT, response.status_code, response.content)