Adding/updating copyrights plus some unittests
[optf/osdf.git] / test / test_process_placement_opt.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 unittest
19 import json
20 import yaml
21 from osdf.optimizers.placementopt.conductor.remote_opt_processor import process_placement_opt
22 from mock import patch
23
24 class TestConductorApiBuilder(unittest.TestCase):
25
26     def test_conductor_api_call_builder(self):
27         #main_dir = ".."
28         main_dir = ""
29         conductor_api_template = main_dir + "osdf/templates/conductor_interface.json"
30         parameter_data_file = main_dir + "test/placement-tests/request.json"
31         policy_data_path = main_dir + "test/policy-local-files/"
32         local_config_file = main_dir + "config/common_config.yaml"
33
34         policy_data_files = ["CloudAttributePolicy_vGMuxInfra_1.json",
35                             "CloudAttributePolicy_vG_1.json",
36                             "DistanceToLocationPolicy_vGMuxInfra_1.json",
37                             "DistanceToLocationPolicy_vG_1.json",
38                             "InventoryGroup_vGMuxInfra_1.json",
39                             "InventoryGroup_vG_1.json",
40                             "PlacementOptimizationPolicy.json",
41                             "ResourceInstancePolicy_vG_1.json",
42                             "VNFPolicy_vGMuxInfra_1.json",
43                             "VNFPolicy_vG_1.json",
44                             "ZonePolicy_vGMuxInfra_1.json",
45                             "ZonePolicy_vG_1.json"]
46         request_json = json.loads(open(parameter_data_file).read())
47         policies = [json.loads(open(policy_data_path + file).read()) for file in policy_data_files]
48         local_config = yaml.load(open(local_config_file))
49         with patch('osdf.optimizers.placementopt.conductor.conductor.request', return_value={"solutionInfo": {"placementInfo": "dummy"}}):
50             templ_string = process_placement_opt(request_json, policies, local_config, [])
51
52
53 if __name__ == "__main__":
54     unittest.main()
55