blob: 131c94828827b6258abac0840562f877cb5d31a9 [file] [log] [blame]
Xianyuan Jiaae0d41a2019-04-23 15:09:05 -07001#!/usr/bin/env python3
2#
3# Copyright 2019 - The Android Open Source Project
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
17import copy
18import unittest
19
Xianyuan Jia31b53e42019-07-26 12:26:03 -070020from acts.test_utils.instrumentation.instrumentation_base_test import \
21 InstrumentationBaseTest
Xianyuan Jiaae0d41a2019-04-23 15:09:05 -070022
23MOCK_POWER_CONFIG = {
24 'not_file': 'NOT_FILE',
25 'file1': 'FILE',
26 'lvl1': {
27 'file2': 'FILE',
28 'lvl2': {'file1': 'FILE'}
29 }
30}
31
32MOCK_ACTS_USERPARAMS = {
33 'file1': '/path/to/file1',
34 'file2': '/path/to/file2'
35}
36
37
38class MockInstrumentationBaseTest(InstrumentationBaseTest):
39 """Mock test class to initialize required attributes."""
40 def __init__(self):
41 self.user_params = MOCK_ACTS_USERPARAMS
42
43
44class InstrumentationBaseTestTest(unittest.TestCase):
45 def setUp(self):
46 self.instrumentation_test = MockInstrumentationBaseTest()
47
48 def test_resolve_files_from_config(self):
49 """Test that params with the 'FILE' marker are properly substituted
50 with the corresponding paths from ACTS user_params.
51 """
52 mock_config = copy.deepcopy(MOCK_POWER_CONFIG)
53 self.instrumentation_test._resolve_file_paths(mock_config)
54 self.assertEqual(mock_config['not_file'], MOCK_POWER_CONFIG['not_file'])
55 self.assertEqual(mock_config['file1'], MOCK_ACTS_USERPARAMS['file1'])
56 self.assertEqual(mock_config['lvl1']['file2'],
57 MOCK_ACTS_USERPARAMS['file2'])
58 self.assertEqual(mock_config['lvl1']['lvl2']['file1'],
59 MOCK_ACTS_USERPARAMS['file1'])
60
61
62if __name__ == '__main__':
63 unittest.main()