update link to upper-constraints.txt
[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         self.template_fields = {
39             'location_enabled': True,
40             'version': '2017-10-10'
41         }
42
43     def tearDown(self):
44         pass
45
46     def test_request(self):
47         req_json = json_from_file("./test/placement-tests/request.json")
48         policies = pol.get_local_policies("test/policy-local-files/", self.lp)
49         req_info = req_json['requestInfo']
50         demands = req_json['placementInfo']['placementDemands']
51         request_parameters = req_json['placementInfo']['requestParameters']
52         service_info = req_json['serviceInfo']
53         conductor.request(req_info, demands, request_parameters, service_info, self.template_fields,
54                           self.osdf_config, policies)
55
56     def test_request_vfmod(self):
57         req_json = json_from_file("./test/placement-tests/request_vfmod.json")
58         policies = pol.get_local_policies("test/policy-local-files/", self.lp)
59         req_info = req_json['requestInfo']
60         demands = req_json['placementInfo']['placementDemands']
61         request_parameters = req_json['placementInfo']['requestParameters']
62         service_info = req_json['serviceInfo']
63         conductor.request(req_info, demands, request_parameters, service_info, self.template_fields,
64                           self.osdf_config, policies)
65
66
67 if __name__ == "__main__":
68     unittest.main()
69