blob: 963a330d35fba1addd3f12373185c5d4c9bd87f9 [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
20from acts.test_utils.instrumentation_tests.instrumentation_base_test import InstrumentationBaseTest
21
22MOCK_POWER_CONFIG = {
23 'not_file': 'NOT_FILE',
24 'file1': 'FILE',
25 'lvl1': {
26 'file2': 'FILE',
27 'lvl2': {'file1': 'FILE'}
28 }
29}
30
31MOCK_ACTS_USERPARAMS = {
32 'file1': '/path/to/file1',
33 'file2': '/path/to/file2'
34}
35
36
37class MockInstrumentationBaseTest(InstrumentationBaseTest):
38 """Mock test class to initialize required attributes."""
39 def __init__(self):
40 self.user_params = MOCK_ACTS_USERPARAMS
41
42
43class InstrumentationBaseTestTest(unittest.TestCase):
44 def setUp(self):
45 self.instrumentation_test = MockInstrumentationBaseTest()
46
47 def test_resolve_files_from_config(self):
48 """Test that params with the 'FILE' marker are properly substituted
49 with the corresponding paths from ACTS user_params.
50 """
51 mock_config = copy.deepcopy(MOCK_POWER_CONFIG)
52 self.instrumentation_test._resolve_file_paths(mock_config)
53 self.assertEqual(mock_config['not_file'], MOCK_POWER_CONFIG['not_file'])
54 self.assertEqual(mock_config['file1'], MOCK_ACTS_USERPARAMS['file1'])
55 self.assertEqual(mock_config['lvl1']['file2'],
56 MOCK_ACTS_USERPARAMS['file2'])
57 self.assertEqual(mock_config['lvl1']['lvl2']['file1'],
58 MOCK_ACTS_USERPARAMS['file1'])
59
60
61if __name__ == '__main__':
62 unittest.main()