Merge "fix csit, cleanup dockerfile for osdf"
[optf/osdf.git] / test / test_get_opt_query_data.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 from apps.placement.optimizers.conductor.translation import get_opt_query_data
21
22
23 class TestGetOptQueryData(unittest.TestCase):
24
25     def test_get_opt_query_data(self):
26         main_dir = ""
27         parameter_data_file = main_dir + "test/placement-tests/request.json"
28         policy_data_path = main_dir + "test/policy-local-files/"
29
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)
34
35         self.assertTrue(req_param_dict is not None)
36
37     def test_get_opt_query_data_vfmod(self):
38         main_dir = ""
39         parameter_data_file = main_dir + "test/placement-tests/request_vfmod.json"
40         policy_data_path = main_dir + "test/policy-local-files/"
41
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)
46
47         self.assertTrue(req_param_dict is not None)
48
49
50 if __name__ == "__main__":
51     unittest.main()
52