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
17 from rest_framework import status
18 from lcm.pub.utils import restcall
19 from lcm.pub.database.models import FPInstModel
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 FPInstModel(fpinstid="fp_inst_1", fpid="fpd_1", sdncontrollerid="test").save()
31 FPInstModel.objects.all().delete()
33 @mock.patch.object(restcall, 'call_req')
34 def test_create_flow_classifier_success(self, mock_call_req):
36 "fpinstid": "fp_inst_1",
37 "context": json.dumps(nsd_model)
40 "/external-system/esr-thirdparty-sdnc-list/esr-thirdparty-sdnc/test?depth=all":
41 [0, json.JSONEncoder().encode({
42 "thirdparty-sdnc-id": "1",
43 "esr-system-info-list": {
45 "service-url": "url_1",
46 "thirdparty-sdnc-id": "1",
52 "product-name": "bbb",
57 "/api/ztesdncdriver/v1/createflowclassfier":
58 [0, json.JSONEncoder().encode({"id": "test_id_1"}), '200'],
59 "/api/microservices/v1/services":
64 def side_effect(*args):
65 return mock_vals[args[4]]
67 mock_call_req.side_effect = side_effect
68 resp = self.client.post("/api/nslcm/v1/ns/create_flow_classifier", data)
69 ret = FPInstModel.objects.get(fpinstid="fp_inst_1")
70 self.assertEqual(resp.status_code, status.HTTP_200_OK)
71 self.assertEqual("test_id_1", ret.flowclassifiers)