Use subid and const mts for routing, open id range
[ric-plt/a1.git] / tests / conftest.py
1 """
2 pytest conftest
3 """
4 # ==================================================================================
5 #       Copyright (c) 2019 Nokia
6 #       Copyright (c) 2018-2019 AT&T Intellectual Property.
7 #
8 #   Licensed under the Apache License, Version 2.0 (the "License");
9 #   you may not use this file except in compliance with the License.
10 #   You may obtain a copy of the License at
11 #
12 #          http://www.apache.org/licenses/LICENSE-2.0
13 #
14 #   Unless required by applicable law or agreed to in writing, software
15 #   distributed under the License is distributed on an "AS IS" BASIS,
16 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 #   See the License for the specific language governing permissions and
18 #   limitations under the License.
19 # ==================================================================================
20 import tempfile
21 import os
22 import pytest
23 from a1 import app
24
25
26 @pytest.fixture
27 def client():
28     """
29     http://flask.pocoo.org/docs/1.0/testing/
30     """
31
32     db_fd, app.app.config["DATABASE"] = tempfile.mkstemp()
33     app.app.config["TESTING"] = True
34     cl = app.app.test_client()
35
36     yield cl
37
38     os.close(db_fd)
39     os.unlink(app.app.config["DATABASE"])
40
41
42 @pytest.fixture
43 def adm_type_good():
44     """
45     represents a good put for adm control type
46     """
47     return {
48         "name": "Admission Control",
49         "description": "various parameters to control admission of dual connection",
50         "policy_type_id": 6660666,
51         "create_schema": {
52             "$schema": "http://json-schema.org/draft-07/schema#",
53             "type": "object",
54             "properties": {
55                 "enforce": {"type": "boolean", "default": True},
56                 "window_length": {
57                     "type": "integer",
58                     "default": 1,
59                     "minimum": 1,
60                     "maximum": 60,
61                     "description": "Sliding window length (in minutes)",
62                 },
63                 "blocking_rate": {
64                     "type": "number",
65                     "default": 10,
66                     "minimum": 1,
67                     "maximum": 100,
68                     "description": "% Connections to block",
69                 },
70                 "trigger_threshold": {
71                     "type": "integer",
72                     "default": 10,
73                     "minimum": 1,
74                     "description": "Minimum number of events in window to trigger blocking",
75                 },
76             },
77             "required": ["enforce", "blocking_rate", "trigger_threshold", "window_length"],
78             "additionalProperties": False,
79         },
80     }
81
82
83 @pytest.fixture
84 def adm_instance_good():
85     """
86     represents a good put for adm control instance
87     """
88     return {"enforce": True, "window_length": 10, "blocking_rate": 20, "trigger_threshold": 10}