Kuang-che Wu | 6e4beca | 2018-06-27 17:45:02 +0800 | [diff] [blame] | 1 | # -*- coding: utf-8 -*- |
Kuang-che Wu | 708310b | 2018-03-28 17:24:34 +0800 | [diff] [blame] | 2 | # Copyright 2018 The Chromium OS Authors. All rights reserved. |
| 3 | # Use of this source code is governed by a BSD-style license that can be |
| 4 | # found in the LICENSE file. |
| 5 | """Test switch_arc_prebuilt script.""" |
| 6 | |
| 7 | from __future__ import print_function |
| 8 | import unittest |
| 9 | |
Kuang-che Wu | a572349 | 2019-11-25 20:59:34 +0800 | [diff] [blame] | 10 | try: |
| 11 | from unittest import mock |
| 12 | except ImportError: |
| 13 | # TODO(kcwu): remove once migrated to python3 |
| 14 | import mock |
Kuang-che Wu | 708310b | 2018-03-28 17:24:34 +0800 | [diff] [blame] | 15 | |
| 16 | import switch_arc_prebuilt |
| 17 | |
| 18 | |
| 19 | @mock.patch('bisect_kit.common.config_logging', mock.Mock()) |
| 20 | class TestSwitchArcPrebuilt(unittest.TestCase): |
| 21 | """Test switch_arc_prebuilt.py.""" |
| 22 | |
Kuang-che Wu | 0d90b4d | 2019-08-28 01:17:24 +0800 | [diff] [blame] | 23 | @mock.patch('bisect_kit.cros_util.is_good_dut', lambda *_: True) |
Kuang-che Wu | 708310b | 2018-03-28 17:24:34 +0800 | [diff] [blame] | 24 | @mock.patch('bisect_kit.cros_util.query_dut_lsb_release') |
| 25 | @mock.patch('bisect_kit.arc_util.query_flavor') |
| 26 | @mock.patch('bisect_kit.arc_util.push_prebuilt_to_device') |
| 27 | def test_main(self, push_prebuilt_to_device, query_flavor, |
| 28 | query_dut_lsb_release): |
Kuang-che Wu | 708310b | 2018-03-28 17:24:34 +0800 | [diff] [blame] | 29 | dut = 'this_is_dut' |
| 30 | flavor = 'detected_flavor' |
| 31 | bid = '123456789' |
| 32 | query_flavor.return_value = flavor |
| 33 | query_dut_lsb_release.return_value = { |
| 34 | 'CHROMEOS_ARC_VERSION': flavor + '_' + bid |
| 35 | } |
| 36 | |
Kuang-che Wu | 8971607 | 2019-09-04 15:01:53 +0800 | [diff] [blame] | 37 | switch_arc_prebuilt.main(['--dut', dut, bid]) |
Kuang-che Wu | 94ef56e | 2019-01-15 21:17:42 +0800 | [diff] [blame] | 38 | push_prebuilt_to_device.assert_called_with(dut, flavor, bid) |
Kuang-che Wu | 708310b | 2018-03-28 17:24:34 +0800 | [diff] [blame] | 39 | |
| 40 | |
| 41 | if __name__ == '__main__': |
| 42 | unittest.main() |