Merge "Change to support PCI unchangeable cells"
[optf/osdf.git] / test / conductor / test_conductor_calls.py
1 # -------------------------------------------------------------------------
2 #   Copyright (c) 2018 AT&T Intellectual Property
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 import unittest
20
21 from osdf.adapters.conductor import conductor
22 import osdf.config.loader as config_loader
23 from osdf.utils.interfaces import json_from_file
24 from osdf.utils.programming_utils import DotDict
25 from osdf.adapters.policy import interface as pol
26
27
28 class TestConductorCalls(unittest.TestCase):
29
30     def setUp(self):
31         self.config_spec = {
32             "deployment": "test/functest/simulators/simulated-config/osdf_config.yaml",
33             "core": "test/functest/simulators/simulated-config/common_config.yaml"
34         }
35         self.osdf_config = DotDict(config_loader.all_configs(**self.config_spec))
36         self.lp = self.osdf_config.core.get('osdf_temp', {}).get('local_policies', {}
37                                                                  ).get('placement_policy_files_vcpe')
38
39     def tearDown(self):
40         pass
41
42     def test_request(self):
43         req_json = json_from_file("./test/placement-tests/request.json")
44         policies = pol.get_local_policies("test/policy-local-files/", self.lp)
45         req_info = req_json['requestInfo']
46         demands = req_json['placementInfo']['placementDemands']
47         request_parameters = req_json['placementInfo']['requestParameters']
48         service_info = req_json['serviceInfo']
49         conductor.request(req_info, demands, request_parameters, service_info, True, self.osdf_config, policies)
50
51     def test_request_vfmod(self):
52         req_json = json_from_file("./test/placement-tests/request_vfmod.json")
53         policies = pol.get_local_policies("test/policy-local-files/", self.lp)
54         req_info = req_json['requestInfo']
55         demands = req_json['placementInfo']['placementDemands']
56         request_parameters = req_json['placementInfo']['requestParameters']
57         service_info = req_json['serviceInfo']
58         conductor.request(req_info, demands, request_parameters, service_info, True, self.osdf_config, policies)
59
60
61 if __name__ == "__main__":
62     unittest.main()
63