b277b6ab2513e22c0275bc996bb4d7dc5294c22c
[optf/osdf.git] / test / conductor / test_conductor_translation.py
1 # -------------------------------------------------------------------------
2 #   Copyright (c) 2017-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 mock
19 import unittest
20
21 from flask import Response
22 from mock import patch
23 from osdf.adapters.local_data import local_policies
24 from osdf.optimizers.placementopt.conductor import translation as tr
25 from osdf.utils.interfaces import json_from_file, yaml_from_file
26
27
28 class TestConductorTranslation(unittest.TestCase):
29
30     def setUp(self):
31         main_dir = ""
32         conductor_api_template = main_dir + "osdf/templates/conductor_interface.json"
33         parameter_data_file = main_dir + "test/placement-tests/request.json"
34         policy_data_path = main_dir + "test/policy-local-files/"
35         local_config_file = main_dir + "config/common_config.yaml"
36
37         valid_policies_list_file = policy_data_path + '/' + 'meta-valid-policies.txt'
38         valid_policies_files = local_policies.get_policy_names_from_file(valid_policies_list_file)
39
40         self.request_json = json_from_file(parameter_data_file)
41         self.policies = [json_from_file(policy_data_path + '/' + name) for name in valid_policies_files]
42
43     def tearDown(self):
44         pass
45
46     def test_gen_demands(self):
47         res = tr.gen_demands(self.request_json, self.policies)
48         assert res is not None
49
50
51 if __name__ == "__main__":
52     unittest.main()
53