update link to upper-constraints.txt
[optf/osdf.git] / test / test_get_opt_query_data.py
1 # -------------------------------------------------------------------------
2 #   Copyright (c) 2017-2018 AT&T Intellectual Property
3 #   Copyright (C) 2020 Wipro Limited.
4 #
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
8 #
9 #       http://www.apache.org/licenses/LICENSE-2.0
10 #
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.
16 #
17 # -------------------------------------------------------------------------
18 #
19 import unittest
20 import json
21 from osdf.adapters.conductor.translation import get_opt_query_data
22
23
24 class TestGetOptQueryData(unittest.TestCase):
25
26     def test_get_opt_query_data(self):
27         main_dir = ""
28         parameter_data_file = main_dir + "test/placement-tests/request.json"
29         policy_data_path = main_dir + "test/policy-local-files/"
30
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)
35
36         self.assertTrue(req_param_dict is not None)
37
38     def test_get_opt_query_data_vfmod(self):
39         main_dir = ""
40         parameter_data_file = main_dir + "test/placement-tests/request_vfmod.json"
41         policy_data_path = main_dir + "test/policy-local-files/"
42
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)
47
48         self.assertTrue(req_param_dict is not None)
49
50
51 if __name__ == "__main__":
52     unittest.main()
53