Index: appengine/findit/waterfall/test/wf_configured_test_case.py |
diff --git a/appengine/findit/waterfall/test/wf_configured_test_case.py b/appengine/findit/waterfall/test/wf_configured_test_case.py |
new file mode 100644 |
index 0000000000000000000000000000000000000000..5d14fd248b5faff95723b1fc3a41943d45f5bd4a |
--- /dev/null |
+++ b/appengine/findit/waterfall/test/wf_configured_test_case.py |
@@ -0,0 +1,107 @@ |
+# Copyright 2016 The Chromium Authors. All rights reserved. |
+# Use of this source code is governed by a BSD-style license that can be |
+# found in the LICENSE file. |
+ |
+from testing_utils import testing |
+ |
+from model.wf_config import FinditConfig |
+ |
+ |
+_DEFAULT_STEPS_FOR_MASTERS_RULES = { |
+ 'supported_masters': { |
+ 'm': { |
+ 'check_global': True |
+ }, |
+ 'm3': { |
+ 'check_global': True |
+ }, |
+ 'master1': { |
+ # supported_steps override global. |
+ 'supported_steps': ['step6'], |
+ 'unsupported_steps': ['unsupported_step1', |
+ 'unsupported_step2', |
+ 'unsupported_step3'], |
+ 'check_global': True |
+ }, |
+ 'master2': { |
+ # Only supports step4 and step5 regardless of global. |
+ 'supported_steps': ['step4', 'step5'], |
+ 'check_global': False |
+ }, |
+ 'master3': { |
+ # Supports everything not blacklisted in global. |
+ 'check_global': True |
+ }, |
+ }, |
+ 'global': { |
+ # Blacklists all listed steps for all masters unless overridden. |
+ 'unsupported_steps': ['step6', 'step7'], |
+ } |
+} |
+ |
+ |
+_DEFAULT_TRY_BOT_MAPPING = { |
+ 'master1': { |
+ 'builder1': { |
+ 'mastername': 'tryserver1', |
+ 'buildername': 'trybot1', |
+ 'strict_regex': True, |
+ } |
+ }, |
+ 'm': { |
+ 'b': { |
+ 'mastername': 'tryserver.master', |
+ 'buildername': 'tryserver.builder', |
+ } |
+ } |
+} |
+ |
+ |
+_DEFAULT_TRY_JOB_SETTINGS = { |
+ 'server_query_interval_seconds': 60, |
+ 'job_timeout_hours': 5, |
+ 'allowed_response_error_times': 5 |
+} |
+ |
+ |
+_DEFAULT_SWARMING_SETTINGS = { |
+ 'server_host': 'chromium-swarm.appspot.com', |
+ 'default_request_priority': 150, |
+ 'request_expiration_hours': 20, |
+ 'server_query_interval_seconds': 60, |
+ 'task_timeout_hours': 23, |
+ 'isolated_server': 'https://isolateserver.appspot.com', |
+ 'isolated_storage_url': 'isolateserver.storage.googleapis.com', |
+ 'iterations_to_rerun': 10 |
+} |
+ |
+ |
+DEFAULT_UNIT_TEST_CONFIG_DATA = { |
+ 'steps_for_masters_rules': _DEFAULT_STEPS_FOR_MASTERS_RULES, |
+ 'builders_to_trybots': _DEFAULT_TRY_BOT_MAPPING, |
+ 'try_job_settings': _DEFAULT_TRY_JOB_SETTINGS, |
+ 'swarming_settings': _DEFAULT_SWARMING_SETTINGS |
+} |
+ |
+ |
+def MockConfigSettings(config_data=None): # pragma: no cover. |
+ """Sets up Findit's config for unit tests. |
+ |
+ Args: |
+ config_data: a dict containing the config Findit should use for unit tests. |
+ If None, then a default config is used. |
+ """ |
+ |
+ if config_data is None: |
+ FinditConfig.Get().Update(**DEFAULT_UNIT_TEST_CONFIG_DATA) |
+ else: |
+ FinditConfig.Get().Update(**config_data) |
+ |
+ |
+class WaterfallConfiguredTestCase(testing.AppengineTestCase): |
stgao
2016/03/31 18:07:13
nit: WaterfallConfiguredTestCase --> WaterfallTest
lijeffrey
2016/03/31 22:50:20
Done.
|
+ |
+ def setUp(self): # pragma: no cover. |
+ super(WaterfallConfiguredTestCase, self).setUp() |
+ self.mock_current_user(user_email='test@chromium.org', is_admin=True) |
+ MockConfigSettings() |
+ self.mock_current_user() |