blob: f3abd4080f419e42f3f1cfa633d353d3a3d4564b [file] [log] [blame]
Richard Barnette6c2b70a2017-01-26 13:40:51 -08001# Copyright 2017 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
5import unittest
6
7import common
8from autotest_lib.server.cros import provision
9
10_CROS_VERSION_SAMPLES = ['cave-release/R57-9030.0.0']
11_ANDROID_VERSION_SAMPLES = ['git_mnc-release/shamu-userdebug/2457013']
12_TESTBED_VERSION_SAMPLES = [
13 ','.join(_ANDROID_VERSION_SAMPLES * 2),
14 _ANDROID_VERSION_SAMPLES[0] + '#4'
15]
16
17class ImageParsingTests(unittest.TestCase):
18 """Unit tests for `provision.get_version_label_prefix()`."""
19
20 def _do_test_prefixes(self, expected, version_samples):
21 for v in version_samples:
22 prefix = provision.get_version_label_prefix(v)
23 self.assertEqual(prefix, expected)
24
25 def test_cros_prefix(self):
26 """Test handling of Chrome OS version strings."""
27 self._do_test_prefixes(provision.CROS_VERSION_PREFIX,
28 _CROS_VERSION_SAMPLES)
29
30 def test_android_prefix(self):
31 """Test handling of Android version strings."""
32 self._do_test_prefixes(provision.ANDROID_BUILD_VERSION_PREFIX,
33 _ANDROID_VERSION_SAMPLES)
34
35 def test_testbed_prefix(self):
36 """Test handling of Testbed version strings."""
37 self._do_test_prefixes(provision.TESTBED_BUILD_VERSION_PREFIX,
38 _TESTBED_VERSION_SAMPLES)
39
40
41if __name__ == '__main__':
42 unittest.main()