remove swagger test function
[vfc/nfvo/lcm.git] / lcm / ns / tests / test_ns_instant.py
1 # Copyright 2016 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 # from rest_framework import status
16 from django.test import TestCase
17 from django.test import Client
18
19 from lcm.pub.database.models import NSInstModel
20
21
22 class TestNsInstant(TestCase):
23     def setUp(self):
24         self.client = Client()
25         NSInstModel.objects.filter().delete()
26         self.context = '{"vnfs": ["a", "b"], "sfcs": ["c"], "vls": ["d", "e", "f"]}'
27         NSInstModel(id="123", nspackage_id="7", nsd_id="2").save()
28
29     def tearDown(self):
30         pass
31
32     """
33     @mock.patch.object(restcall, 'call_req')
34     @mock.patch.object(toscautil, 'convert_nsd_model')
35     def test_ns_instant_ok(self, mock_convert_nsd_model, mock_call_req):
36         mock_convert_nsd_model.return_value = self.context
37         mock_vals = {
38             "/api/catalog/v1/csars/7/files?relativePath=abc.yaml":
39                 [0, '{"downloadUri":"http://test.yaml", "localPath":"./test.yaml"}', '200'],
40             "/api/tosca/v1/indirect/plan":
41                 [0, '{"description":"", "metadata":{}, "nodes":[]}', '200'],
42             "/api/catalog/v1/servicetemplates/2/operations":
43                 [0, '[{"name":"LCM", "processId":"{http://www.open-o.org/tosca/nfv/2015/12}init-16"}]', '200'],
44             "/api/wso2bpel/v1/process/instance":
45                 [0, '{"status": 1}', '200']}
46
47         def side_effect(*args):
48             return mock_vals[args[4]]
49
50         mock_call_req.side_effect = side_effect
51
52         data = {'iaUrl': "", 'vnfmId': "", 'context': "{\"e\":{\"f\":\"4\"}}", 'statusUrl': "",
53                 'serviceTemplateId': "", 'roUrl': "", 'containerapiUrl': "", 'flavor': "",
54                 'nsInstanceId': "123", 'instanceId': "234", 'resourceUrl': "", 'callbackId': "",
55                 'additionalParamForVnf': "[{\"b\":1},{\"c\":{\"d\":\"2\"}}]",
56                 'additionalParamForNs': "[{\"a\":3},{\"e\":{\"f\":\"4\"}}]", 'flavorParams': ""}
57         resp = self.client.post("/api/nslcm/v1/ns/123/instantiate", data, format='json')
58         self.assertEqual(resp.status_code, status.HTTP_200_OK)
59
60
61     def test_swagger_ok(self):
62         resp = self.client.get("/api/nslcm/v1/swagger.json", format='json')
63         self.assertEqual(resp.status_code, status.HTTP_200_OK)
64     """