update link to upper-constraints.txt
[vfc/nfvo/lcm.git] / lcm / ns / tests / test_sol_update_ns_api.py
1 # Copyright 2019 ZTE Corporation.
2 #
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
6 #
7 #         http://www.apache.org/licenses/LICENSE-2.0
8 #
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.
14
15 import json
16
17 import mock
18 from django.test import TestCase
19 from rest_framework import status
20 from rest_framework.test import APIClient
21 from lcm.pub.database.models import NSInstModel
22 from lcm.ns.biz.ns_update import NSUpdateService
23 from lcm.ns.tests import NSD_MODEL_DICT
24
25
26 class TestUpdateNSApi(TestCase):
27
28     def setUp(self):
29         self.apiClient = APIClient()
30         self.format = "json"
31         self.url = "/api/nslcm/v1/ns_instances/test_update_ns/update"
32         self.data = {"updateType": "ADD_VNF"}
33         NSInstModel(id="test_update_ns", name="test_ns_instance_name", nsd_id="test_nsd_id",
34                     nsd_invariant_id="test_nsd_invariant_id", nsd_model=json.dumps(NSD_MODEL_DICT)).save()
35
36     def tearDown(self):
37         NSInstModel.objects.all().delete()
38
39     @mock.patch.object(NSUpdateService, 'run')
40     def test_create_ns(self, mock_run):
41         response = self.client.post(self.url, data=self.data, format='json')
42         self.assertEqual(status.HTTP_202_ACCEPTED, response.status_code)