"Derive Coverage Area TA list from coverage area"
[optf/has.git] / conductor / conductor / tests / unit / data / plugins / inventory_provider / test_candidates.py
1 #
2 # -------------------------------------------------------------------------
3 #   Copyright (C) 2020 Wipro Limited.
4 #
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
8 #
9 #       http://www.apache.org/licenses/LICENSE-2.0
10 #
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.
16 #
17 # -------------------------------------------------------------------------
18 #
19
20 import unittest
21 import uuid
22
23 from conductor.data.plugins.inventory_provider.candidates.candidate import Candidate
24 from conductor.data.plugins.inventory_provider.candidates.slice_profiles_candidate import SliceProfilesCandidate
25
26 class TestCandidates(unittest.TestCase):
27
28     def setUp(self):
29         pass
30
31     def tearDown(self):
32         pass
33
34     def test_slice_profiles_candidate(self):
35         id = str(uuid.uuid4())
36         expected_candidate = {
37                                 "candidate_id": id,
38                                 "core_latency": 15,
39                                 "core_reliability": 99.99,
40                                 "cost": 1.0,
41                                 "coverage_area": "City: Chennai",
42                                 "inventory_provider": "generator",
43                                 "inventory_type": "slice_profiles",
44                                 "latency": 25,
45                                 "ran_coverage_area_ta_list": "City: Chennai",
46                                 "ran_latency": 10,
47                                 "ran_reliability": 99.99,
48                                 "reliability": 99.99,
49                                 "uniqueness": "true",
50                                 "creation_cost": 0.9
51                             }
52         info = Candidate.build_candidate_info("generator", "slice_profiles", 1.0, "true", id)
53         subnet_requirements = {"core": {"latency": 15, "reliability": 99.99},
54                                "ran": {"latency": 10, "reliability": 99.99, "coverage_area_ta_list": "City: Chennai"}
55                                }
56
57         candidate = SliceProfilesCandidate(info=info, subnet_requirements=subnet_requirements,
58                                            default_fields={"creation_cost": 0.9},coverage_area="City: Chennai")
59
60         self.assertEqual(expected_candidate, candidate.convert_nested_dict_to_dict())