blob: bf588c640670e33e20bd3d71e06cc91b2e2cce75 [file] [log] [blame]
Kuang-che Wu6e4beca2018-06-27 17:45:02 +08001# -*- coding: utf-8 -*-
Kuang-che Wu708310b2018-03-28 17:24:34 +08002# 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
7from __future__ import print_function
8import unittest
9
10import mock
11
12import switch_arc_prebuilt
13
14
15@mock.patch('bisect_kit.common.config_logging', mock.Mock())
16class TestSwitchArcPrebuilt(unittest.TestCase):
17 """Test switch_arc_prebuilt.py."""
18
19 @mock.patch('bisect_kit.cli.argtype_dir_path', lambda x: x)
20 @mock.patch('bisect_kit.cros_util.query_dut_lsb_release')
21 @mock.patch('bisect_kit.arc_util.query_flavor')
22 @mock.patch('bisect_kit.arc_util.push_prebuilt_to_device')
23 def test_main(self, push_prebuilt_to_device, query_flavor,
24 query_dut_lsb_release):
25 android_root = '/path/to/android/repo'
26 dut = 'this_is_dut'
27 flavor = 'detected_flavor'
28 bid = '123456789'
29 query_flavor.return_value = flavor
30 query_dut_lsb_release.return_value = {
31 'CHROMEOS_ARC_VERSION': flavor + '_' + bid
32 }
33
34 switch_arc_prebuilt.main(['--android_root', android_root, dut, bid])
35 push_prebuilt_to_device.assert_called_with(
36 dut, flavor, bid, android_root=android_root)
37
38 switch_arc_prebuilt.main([dut, bid])
39 push_prebuilt_to_device.assert_called_with(
40 dut, flavor, bid, android_root=None)
41
42
43if __name__ == '__main__':
44 unittest.main()