blob: 56f5948f3ea8973534fd1d6e204d84b5c4066f57 [file] [log] [blame]
Allen Li606673f2017-02-21 18:41:13 -08001#!/usr/bin/python2.7
Richard Barnette6c2b70a2017-01-26 13:40:51 -08002# Copyright 2017 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.cros import provision
10
11_CROS_VERSION_SAMPLES = ['cave-release/R57-9030.0.0']
12_ANDROID_VERSION_SAMPLES = ['git_mnc-release/shamu-userdebug/2457013']
Richard Barnette6c2b70a2017-01-26 13:40:51 -080013
Allen Li606673f2017-02-21 18:41:13 -080014
15class ActionTestCase(unittest.TestCase):
16 """Tests for Action functions."""
Richard Barnette17fa7c42018-04-26 00:33:11 +000017 #pylint:disable=missing-docstring
Allen Li606673f2017-02-21 18:41:13 -080018
19 def test__get_label_action_with_keyval_label(self):
20 got = provision._get_label_action('cros-version:foo')
21 self.assertEqual(got, provision._Action('cros-version', 'foo'))
22
23 def test__get_label_action_with_plain_label(self):
24 got = provision._get_label_action('webcam')
25 self.assertEqual(got, provision._Action('webcam', None))
26
27 def test__get_label_action_with_empty_string(self):
28 got = provision._get_label_action('')
29 self.assertEqual(got, provision._Action('', None))
30
31
Richard Barnette6c2b70a2017-01-26 13:40:51 -080032class ImageParsingTests(unittest.TestCase):
33 """Unit tests for `provision.get_version_label_prefix()`."""
34
35 def _do_test_prefixes(self, expected, version_samples):
36 for v in version_samples:
37 prefix = provision.get_version_label_prefix(v)
38 self.assertEqual(prefix, expected)
39
40 def test_cros_prefix(self):
41 """Test handling of Chrome OS version strings."""
42 self._do_test_prefixes(provision.CROS_VERSION_PREFIX,
43 _CROS_VERSION_SAMPLES)
44
45 def test_android_prefix(self):
46 """Test handling of Android version strings."""
47 self._do_test_prefixes(provision.ANDROID_BUILD_VERSION_PREFIX,
48 _ANDROID_VERSION_SAMPLES)
49
Richard Barnette6c2b70a2017-01-26 13:40:51 -080050
51if __name__ == '__main__':
52 unittest.main()