1 # Copyright 2016 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 test_data import nsd_model, vnfd_model_dict1, vnfd_model_dict2
17 # from rest_framework import status
18 # from lcm.pub.utils import restcall
19 # from lcm.pub.database.models import FPInstModel, NfInstModel
20 # from django.test import Client
21 # from django.test import TestCase
24 # class TestSfc(TestCase):
26 # self.client = Client()
27 # FPInstModel.objects.all().delete()
28 # NfInstModel.objects.all().delete()
30 # nfinstid="vnf_inst_1", ns_inst_id="ns_inst_1", vnf_id="vnf_1",
31 # vnfd_model=json.dumps(vnfd_model_dict1)).save()
33 # nfinstid="vnf_inst_2", vnf_id="vnf_2", ns_inst_id="ns_inst_1",
34 # vnfd_model=json.dumps(vnfd_model_dict2)).save()
36 # fpid="fpd_1", fpinstid="fp_inst_1", nsinstid="ns_inst_1", vnffginstid="vnffg_inst_1",
40 # "dest_port_range": [80, 1024],
41 # "source_port_range": [80, 1024],
42 # "ip_protocol": "tcp",
43 # "dest_ip_range": ["192.168.1.2", "192.168.1.100"],
44 # "source_ip_range": ["192.168.1.2", "192.168.1.100"],
49 # sdncontrollerid="sdn_controller_1"
53 # FPInstModel.objects.all().delete()
54 # NfInstModel.objects.all().delete()
56 # @mock.patch.object(restcall, 'call_req')
57 # def test_create_port_pair_group_success(self, mock_call_req):
59 # "nsinstanceid": "ns_inst_1",
60 # "fpinstid": "fp_inst_1",
61 # "context": json.dumps(nsd_model)
64 # "/api/extsys/v1/sdncontrollers/sdn_controller_1":
65 # [0, json.JSONEncoder().encode({"url": "url_1"}), '200'],
66 # "/api/sdncdriver/v1.0/createportpair":
67 # [0, json.JSONEncoder().encode({"id": "createportpair_id"}), '200'],
68 # "/api/sdncdriver/v1.0/createportpairgroup":
69 # [0, json.JSONEncoder().encode({"id": "createportpairgroup_id"}), '200'],
70 # "/api/microservices/v1/services":
74 # def side_effect(*args):
75 # return mock_vals[args[4]]
77 # mock_call_req.side_effect = side_effect
78 # resp = self.client.post("/api/nslcm/v1/ns/create_port_pair_group", data)
79 # rest = json.loads(FPInstModel.objects.get(fpinstid="fp_inst_1").portpairgroups)[0]
80 # self.assertEqual(resp.status_code, status.HTTP_200_OK)
81 # self.assertEqual("createportpairgroup_id", rest["groupid"])