cbuildbot: Setup handling to load site specific configs.
This CL doesn't start fetching site specific config git repositories,
but it sets us up to be able to load then, and creates a place in the
startup work flow to do the fetching.
Also, move configuration file locations from config_lib to
constants.py since the values are now more complicated.
BUG=chromium:497284
TEST=Unittests.
Change-Id: I54bb29df130d8937c4c0c5d99152c9ba63b61508
Reviewed-on: https://chromium-review.googlesource.com/282787
Trybot-Ready: Don Garrett <dgarrett@chromium.org>
Tested-by: Don Garrett <dgarrett@chromium.org>
Reviewed-by: Matthew Sartori <msartori@chromium.org>
Commit-Queue: Don Garrett <dgarrett@chromium.org>
diff --git a/scripts/cbuildbot_unittest.py b/scripts/cbuildbot_unittest.py
index ed36881..58302f9 100644
--- a/scripts/cbuildbot_unittest.py
+++ b/scripts/cbuildbot_unittest.py
@@ -6,11 +6,55 @@
from __future__ import print_function
+import mock
+import os
+
+from chromite.cbuildbot import config_lib
from chromite.cbuildbot import constants
from chromite.lib import cros_test_lib
from chromite.scripts import cbuildbot
+# pylint: disable=protected-access
+
+
+class SiteConfigTests(cros_test_lib.MockTestCase):
+ """Test cbuildbot._SetupSiteConfig."""
+ def setUp(self):
+ self.options = mock.Mock()
+ self.options.config_repo = None
+
+ self.expected_result = mock.Mock()
+
+ self.exists_mock = self.PatchObject(os.path, 'exists')
+ self.load_mock = self.PatchObject(config_lib, 'LoadConfigFromFile',
+ return_value=self.expected_result)
+
+ def testDefaultChromeOsBehavior(self):
+ # Setup Fakes and Mocks.
+ self.exists_mock.return_value = False
+
+ # Run Tests
+ result = cbuildbot._SetupSiteConfig(self.options)
+
+ # Evaluate Results
+ self.assertIs(result, self.expected_result)
+ self.load_mock.assert_called_once_with(constants.CHROMEOS_CONFIG_FILE)
+
+ def testDefaultSiteBehavior(self):
+ # Setup Fakes and Mocks.
+ self.exists_mock.return_value = True
+
+ # Run Tests
+ result = cbuildbot._SetupSiteConfig(self.options)
+
+ # Evaluate Results
+ self.assertIs(result, self.expected_result)
+ self.load_mock.assert_called_once_with(constants.SITE_CONFIG_FILE)
+
+ # TODO(dgarrett): Test a specified site URL, when it's implemented.
+
+
class IsDistributedBuilderTest(cros_test_lib.TestCase):
"""Test for cbuildbot._IsDistributedBuilder."""