• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/python2
2# Copyright 2016 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
6import unittest
7
8import common
9from autotest_lib.server import afe_utils
10
11
12class FakeHostInfo(object):
13    def __init__(self, board, cros_stable_version, servo_cros_stable_version):
14        self._board = board
15        self._cros_stable_version = cros_stable_version
16        self._servo_cros_stable_version = servo_cros_stable_version
17
18    @property
19    def board(self):
20        return self._board
21
22    @property
23    def cros_stable_version(self):
24        return self._cros_stable_version
25
26    @property
27    def servo_cros_stable_version(self):
28        return self._servo_cros_stable_version
29
30
31class AfeUtilsTestCase(unittest.TestCase):
32    def test_get_stable_cros_image_name_v2(self):
33        board = "xxx-board"
34        host_info = FakeHostInfo(
35            board=board,
36            servo_cros_stable_version="some garbage",
37            cros_stable_version="R1-2.3.4"
38        )
39        expected = "xxx-board-release/R1-2.3.4"
40        out = afe_utils.get_stable_cros_image_name_v2(host_info=host_info)
41        self.assertEqual(out, expected)
42
43
44if __name__ == '__main__':
45    unittest.main()
46