blob: 8c7c31db51899e6a6171af4403390420c4868e08 [file] [log] [blame]
Dan Shi70647ca2015-07-16 22:52:35 -07001# Copyright 2015 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.frontend import setup_django_lite_environment
Dan Shi70647ca2015-07-16 22:52:35 -07009from autotest_lib.server import site_utils
10from autotest_lib.server.cros.dynamic_suite import tools
Xixuan Wue3e362f2018-04-26 16:34:28 -070011from autotest_lib.server.cros.dynamic_suite import suite_common
Dan Shi70647ca2015-07-16 22:52:35 -070012
13
14class SiteUtilsUnittests(unittest.TestCase):
Richard Barnette6e991202018-04-16 17:37:55 -070015 """Test functions in site_utils.py"""
Dan Shi70647ca2015-07-16 22:52:35 -070016
17 def testParseJobName(self):
18 """Test method parse_job_name.
19 """
20 trybot_paladin_build = 'trybot-lumpy-paladin/R27-3837.0.0-b123'
21 trybot_release_build = 'trybot-lumpy-release/R27-3837.0.0-b456'
22 release_build = 'lumpy-release/R27-3837.0.0'
23 paladin_build = 'lumpy-paladin/R27-3878.0.0-rc7'
Dan Shief31f032016-05-13 15:51:39 -070024 brillo_build = 'git_mnc-brillo-dev/lumpy-eng/1234'
Dan Shie02810d2016-08-25 09:44:57 -070025 chrome_pfq_build = 'lumpy-chrome-pfq/R27-3837.0.0'
26 chromium_pfq_build = 'lumpy-chromium-pfq/R27-3837.0.0'
Dan Shi70647ca2015-07-16 22:52:35 -070027
28 builds = [trybot_paladin_build, trybot_release_build, release_build,
Dan Shie02810d2016-08-25 09:44:57 -070029 paladin_build, brillo_build, chrome_pfq_build,
30 chromium_pfq_build]
Dan Shi70647ca2015-07-16 22:52:35 -070031 test_name = 'login_LoginSuccess'
32 board = 'lumpy'
33 suite = 'bvt'
34 for build in builds:
35 expected_info = {'board': board,
36 'suite': suite,
Dan Shief31f032016-05-13 15:51:39 -070037 'build': build}
38 build_parts = build.split('/')
39 if len(build_parts) == 2:
40 expected_info['build_version'] = build_parts[1]
41 else:
42 expected_info['build_version'] = build_parts[2]
Dan Shi70647ca2015-07-16 22:52:35 -070043 suite_job_name = ('%s-%s' %
Xixuan Wue3e362f2018-04-26 16:34:28 -070044 (build, suite_common.canonicalize_suite_name(suite)))
Dan Shi70647ca2015-07-16 22:52:35 -070045 info = site_utils.parse_job_name(suite_job_name)
46 self.assertEqual(info, expected_info, '%s failed to be parsed to '
47 '%s' % (suite_job_name, expected_info))
48 test_job_name = tools.create_job_name(build, suite, test_name)
49 info = site_utils.parse_job_name(test_job_name)
50 self.assertEqual(info, expected_info, '%s failed to be parsed to '
51 '%s' % (test_job_name, expected_info))
52
53
Dan Shi70647ca2015-07-16 22:52:35 -070054if __name__ == '__main__':
55 unittest.main()