blob: f540adddb42cbfc53608d83e13920c438c760e20 [file] [log] [blame]
Gaurav Shah298aa372014-01-31 09:27:24 -08001# Copyright (c) 2014 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
5"""Unit tests for the cbuildbot program"""
6
Mike Frysinger383367e2014-09-16 15:06:17 -04007from __future__ import print_function
8
Aviv Keshetb7519e12016-10-04 00:50:00 -07009from chromite.lib import constants
Gaurav Shah298aa372014-01-31 09:27:24 -080010from chromite.lib import cros_test_lib
11from chromite.scripts import cbuildbot
12
13
Don Garrettb85658c2015-06-30 19:07:22 -070014# pylint: disable=protected-access
15
16
Gaurav Shah298aa372014-01-31 09:27:24 -080017class IsDistributedBuilderTest(cros_test_lib.TestCase):
18 """Test for cbuildbot._IsDistributedBuilder."""
19
20 # pylint: disable=W0212
21 def testIsDistributedBuilder(self):
22 """Tests for _IsDistributedBuilder() under various configurations."""
23 parser = cbuildbot._CreateParser()
Paul Hobbs7358a142017-07-26 16:09:36 -070024 argv = ['amd64-generic-paladin']
Don Garrett597ddff2017-02-17 18:29:37 -080025 (options, _) = cbuildbot.ParseCommandLine(parser, argv)
Gaurav Shah298aa372014-01-31 09:27:24 -080026 options.buildbot = False
Gaurav Shah298aa372014-01-31 09:27:24 -080027
28 build_config = dict(pre_cq=False,
29 manifest_version=False)
30 chrome_rev = None
31
32 def _TestConfig(expected):
33 self.assertEquals(expected,
34 cbuildbot._IsDistributedBuilder(
35 options=options,
36 chrome_rev=chrome_rev,
37 build_config=build_config))
38
39 # Default options.
40 _TestConfig(False)
41
Gaurav Shah298aa372014-01-31 09:27:24 -080042 build_config['pre_cq'] = True
43 _TestConfig(True)
44
45 build_config['pre_cq'] = False
46 build_config['manifest_version'] = True
47 # Not running in buildbot mode even though manifest_version=True.
48 _TestConfig(False)
49 options.buildbot = True
50 _TestConfig(True)
51
52 for chrome_rev in (constants.CHROME_REV_TOT,
53 constants.CHROME_REV_LOCAL,
54 constants.CHROME_REV_SPEC):
55 _TestConfig(False)