77d9a72b6bae6c91ab1844013bff75d3d554d426
[optf/osdf.git] / test / conductor / test_conductor_calls.py
1 # -------------------------------------------------------------------------
2 #   Copyright (c) 2018 AT&T Intellectual Property
3 #
4 #   Licensed under the Apache License, Version 2.0 (the "License");
5 #   you may not use this file except in compliance with the License.
6 #   You may obtain a copy of the License at
7 #
8 #       http://www.apache.org/licenses/LICENSE-2.0
9 #
10 #   Unless required by applicable law or agreed to in writing, software
11 #   distributed under the License is distributed on an "AS IS" BASIS,
12 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 #   See the License for the specific language governing permissions and
14 #   limitations under the License.
15 #
16 # -------------------------------------------------------------------------
17 #
18 import unittest
19
20 from osdf.optimizers.placementopt.conductor import conductor
21 import osdf.config.loader as config_loader
22 from osdf.utils.interfaces import json_from_file
23 from osdf.utils.programming_utils import DotDict
24 from osdf.adapters.policy import interface as pol
25
26
27 class TestConductorCalls(unittest.TestCase):
28
29     def setUp(self):
30         self.config_spec = {
31             "deployment": "test/functest/simulators/simulated-config/osdf_config.yaml",
32             "core": "test/functest/simulators/simulated-config/common_config.yaml"
33         }
34         self.osdf_config = DotDict(config_loader.all_configs(**self.config_spec))
35         self.lp = self.osdf_config.core.get('osdf_temp', {}).get('local_policies', {}
36                                                                  ).get('placement_policy_files_vcpe')
37
38     def tearDown(self):
39         pass
40
41     def test_request(self):
42         req_json = json_from_file("./test/placement-tests/request.json")
43         policies = pol.get_local_policies("test/policy-local-files/", self.lp)
44         conductor.request(req_json, self.osdf_config, policies)
45
46     def test_request_vfmod(self):
47         req_json = json_from_file("./test/placement-tests/request_vfmod.json")
48         policies = pol.get_local_policies("test/policy-local-files/", self.lp)
49         conductor.request(req_json, self.osdf_config, policies)
50
51
52 if __name__ == "__main__":
53     unittest.main()
54