1 # -------------------------------------------------------------------------
2 # Copyright (c) 2017-2018 AT&T Intellectual Property
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
8 # http://www.apache.org/licenses/LICENSE-2.0
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.
16 # -------------------------------------------------------------------------
21 from osdf.optimizers.placementopt.conductor.api_builder import conductor_api_builder
24 class TestConductorApiBuilder(unittest.TestCase):
26 def test_conductor_api_call_builder(self):
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"
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 templ_string = conductor_api_builder(request_json, policies, local_config, [], conductor_api_template)
50 templ_json = json.loads(templ_string)
51 self.assertEqual(templ_json["name"], "yyy-yyy-yyyy")
54 if __name__ == "__main__":