blob: 2044d36f781e999a435deef475c5c628c31acf2e [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
Kuang-che Wu23192ad2020-03-11 18:12:46 +080010from unittest import mock
Kuang-che Wu708310b2018-03-28 17:24:34 +080011
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
Kuang-che Wu0d90b4d2019-08-28 01:17:24 +080019 @mock.patch('bisect_kit.cros_util.is_good_dut', lambda *_: True)
Kuang-che Wu708310b2018-03-28 17:24:34 +080020 @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):
Kuang-che Wu708310b2018-03-28 17:24:34 +080025 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
Kuang-che Wu89716072019-09-04 15:01:53 +080033 switch_arc_prebuilt.main(['--dut', dut, bid])
Kuang-che Wu94ef56e2019-01-15 21:17:42 +080034 push_prebuilt_to_device.assert_called_with(dut, flavor, bid)
Kuang-che Wu708310b2018-03-28 17:24:34 +080035
36
37if __name__ == '__main__':
38 unittest.main()