Kuang-che Wu | 708310b | 2018-03-28 17:24:34 +0800 | [diff] [blame] | 1 | # Copyright 2018 The Chromium OS Authors. All rights reserved. |
| 2 | # Use of this source code is governed by a BSD-style license that can be |
| 3 | # found in the LICENSE file. |
| 4 | """Test switch_arc_prebuilt script.""" |
| 5 | |
| 6 | from __future__ import print_function |
| 7 | import unittest |
| 8 | |
| 9 | import mock |
| 10 | |
| 11 | import switch_arc_prebuilt |
| 12 | |
| 13 | |
| 14 | @mock.patch('bisect_kit.common.config_logging', mock.Mock()) |
| 15 | class TestSwitchArcPrebuilt(unittest.TestCase): |
| 16 | """Test switch_arc_prebuilt.py.""" |
| 17 | |
| 18 | @mock.patch('bisect_kit.cli.argtype_dir_path', lambda x: x) |
| 19 | @mock.patch('bisect_kit.cros_util.query_dut_lsb_release') |
| 20 | @mock.patch('bisect_kit.arc_util.query_flavor') |
| 21 | @mock.patch('bisect_kit.arc_util.push_prebuilt_to_device') |
| 22 | def test_main(self, push_prebuilt_to_device, query_flavor, |
| 23 | query_dut_lsb_release): |
| 24 | android_root = '/path/to/android/repo' |
| 25 | dut = 'this_is_dut' |
| 26 | flavor = 'detected_flavor' |
| 27 | bid = '123456789' |
| 28 | query_flavor.return_value = flavor |
| 29 | query_dut_lsb_release.return_value = { |
| 30 | 'CHROMEOS_ARC_VERSION': flavor + '_' + bid |
| 31 | } |
| 32 | |
| 33 | switch_arc_prebuilt.main(['--android_root', android_root, dut, bid]) |
| 34 | push_prebuilt_to_device.assert_called_with( |
| 35 | dut, flavor, bid, android_root=android_root) |
| 36 | |
| 37 | switch_arc_prebuilt.main([dut, bid]) |
| 38 | push_prebuilt_to_device.assert_called_with( |
| 39 | dut, flavor, bid, android_root=None) |
| 40 | |
| 41 | |
| 42 | if __name__ == '__main__': |
| 43 | unittest.main() |