1 # -------------------------------------------------------------------------
2 # Copyright (c) 2017-2018 AT&T Intellectual Property
3 # Copyright (C) 2020 Wipro Limited.
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
9 # http://www.apache.org/licenses/LICENSE-2.0
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.
17 # -------------------------------------------------------------------------
21 from osdf.adapters.conductor.translation import get_opt_query_data
24 class TestGetOptQueryData(unittest.TestCase):
26 def test_get_opt_query_data(self):
28 parameter_data_file = main_dir + "test/placement-tests/request.json"
29 policy_data_path = main_dir + "test/policy-local-files/"
31 query_policy_data_file = ["QueryPolicy_vCPE.json"]
32 request_json = json.loads(open(parameter_data_file).read())
33 policies = [json.loads(open(policy_data_path + file).read()) for file in query_policy_data_file]
34 req_param_dict = get_opt_query_data(request_json['placementInfo']['requestParameters'], policies)
36 self.assertTrue(req_param_dict is not None)
38 def test_get_opt_query_data_vfmod(self):
40 parameter_data_file = main_dir + "test/placement-tests/request_vfmod.json"
41 policy_data_path = main_dir + "test/policy-local-files/"
43 query_policy_data_file = ["QueryPolicy_vFW_TD.json"]
44 request_json = json.loads(open(parameter_data_file).read())
45 policies = [json.loads(open(policy_data_path + file).read()) for file in query_policy_data_file]
46 req_param_dict = get_opt_query_data(request_json['placementInfo']['requestParameters'], policies)
48 self.assertTrue(req_param_dict is not None)
51 if __name__ == "__main__":