summaryrefslogtreecommitdiffstats
path: root/lcm/ns/tests/sfcs/test_create_flow_classifier.py
blob: eb149dcabb5b7d504b1e77959ef7f04d44d0aae6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Copyright 2016 ZTE Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# import mock
# import json
# from test_data import nsd_model
# from rest_framework import status
# from lcm.pub.utils import restcall
# from lcm.pub.database.models import FPInstModel
# from django.test import Client
# from django.test import TestCase
#
#
# class TestSfc(TestCase):
#     def setUp(self):
#         self.client = Client()
#         FPInstModel.objects.all().delete()
#         FPInstModel(fpinstid="fp_inst_1", fpid="fpd_1", sdncontrollerid="test").save()
#
#     def tearDown(self):
#         FPInstModel.objects.all().delete()
#
#     @mock.patch.object(restcall, 'call_req')
#     def test_create_flow_classifier_success(self, mock_call_req):
#         data = {
#             "fpinstid": "fp_inst_1",
#             "context": json.dumps(nsd_model)
#         }
#         mock_vals = {
#             "/openoapi/extsys/v1/sdncontrollers/test":
#                 [0, json.JSONEncoder().encode({"url": "url_1"}), '200'],
#             "/openoapi/sdncdriver/v1.0/createflowclassfier":
#                 [0, json.JSONEncoder().encode({"id": "test_id_1"}), '200'],
#             "/openoapi/microservices/v1/services":
#                 [0, None, '200']
#
#         }
#
#         def side_effect(*args):
#             return mock_vals[args[4]]
#
#         mock_call_req.side_effect = side_effect
#         resp = self.client.post("/openoapi/nslcm/v1/ns/create_flow_classifier", data)
#         ret = FPInstModel.objects.get(fpinstid="fp_inst_1")
#         self.assertEqual(resp.status_code, status.HTTP_200_OK)
#         self.assertEqual("test_id_1", ret.flowclassifiers)