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 # -------------------------------------------------------------------------
20 from apps.placement.optimizers.conductor.translation import get_opt_query_data
23 class TestGetOptQueryData(unittest.TestCase):
25 def test_get_opt_query_data(self):
27 parameter_data_file = main_dir + "test/placement-tests/request.json"
28 policy_data_path = main_dir + "test/policy-local-files/"
30 query_policy_data_file = ["QueryPolicy_vCPE.json"]
31 request_json = json.loads(open(parameter_data_file).read())
32 policies = [json.loads(open(policy_data_path + file).read()) for file in query_policy_data_file]
33 req_param_dict = get_opt_query_data(request_json, policies)
35 self.assertTrue(req_param_dict is not None)
37 def test_get_opt_query_data_vfmod(self):
39 parameter_data_file = main_dir + "test/placement-tests/request_vfmod.json"
40 policy_data_path = main_dir + "test/policy-local-files/"
42 query_policy_data_file = ["QueryPolicy_vFW_TD.json"]
43 request_json = json.loads(open(parameter_data_file).read())
44 policies = [json.loads(open(policy_data_path + file).read()) for file in query_policy_data_file]
45 req_param_dict = get_opt_query_data(request_json, policies)
47 self.assertTrue(req_param_dict is not None)
50 if __name__ == "__main__":