2 # -------------------------------------------------------------------------
3 # Copyright (C) 2020 Wipro Limited.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 # -------------------------------------------------------------------------
22 from conductor.solver.optimizer.constraints.threshold import Threshold
23 from conductor.solver.optimizer.decision_path import DecisionPath
24 from conductor.solver.request.demand import Demand
27 class TestThreshold(unittest.TestCase):
31 candidates_file = './conductor/tests/unit/data/plugins/inventory_provider/nssi_candidate.json'
32 candidates = json.loads(open(candidates_file).read())
34 properties = {'evaluate':
35 [{'attribute': 'latency', 'threshold': 30, 'operator': 'lte'},
36 {'attribute': 'exp_data_rate_ul', 'threshold': 70, 'operator': 'gte'}]}
38 threshold_obj = Threshold('urllc_threshold', 'threshold', ['URLLC'], _priority=0,
39 _properties=properties)
41 decision_path = DecisionPath()
42 decision_path.current_demand = Demand('URLLC')
44 self.assertEqual(candidates, threshold_obj.solve(decision_path, candidates, None))
46 properties = {'evaluate':
47 [{'attribute': 'latency', 'threshold': 10, 'operator': 'lte'},
48 {'attribute': 'exp_data_rate_ul', 'threshold': 120, 'operator': 'gte'}]}
50 threshold_obj = Threshold('urllc_threshold', 'threshold', ['URLLC'], _priority=0,
51 _properties=properties)
53 self.assertEqual([], threshold_obj.solve(decision_path, candidates, None))
56 if __name__ == "__main__":