Chromium Code Reviews| Index: appengine/findit/model/test/configured_test_case.py |
| diff --git a/appengine/findit/model/test/configured_test_case.py b/appengine/findit/model/test/configured_test_case.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e05a784cdc3d87924cfb3b0a388e2dfd1c551693 |
| --- /dev/null |
| +++ b/appengine/findit/model/test/configured_test_case.py |
| @@ -0,0 +1,98 @@ |
| +# Copyright 2016 The Chromium Authors. All rights reserved. |
|
stgao
2016/03/30 01:06:30
Is there a specific reason we wanted to add this m
lijeffrey
2016/03/30 23:28:34
Moved to Findit/waterfall/test
|
| +# 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': ['step1', 'step2', '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, |
| + } |
| + } |
| +} |
| + |
| + |
| +_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): |
| + """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 ConfiguredTestCase(testing.AppengineTestCase): |
|
stgao
2016/03/30 01:06:30
Maybe scope this to Waterfall? Later we might need
lijeffrey
2016/03/30 23:28:34
Done.
|
| + |
| + def setUp(self): |
| + super(ConfiguredTestCase, self).setUp() |
| + self.mock_current_user(user_email='test@chromium.org', is_admin=True) |
|
stgao
2016/03/30 01:06:30
If possible, let's not make this default.
lijeffrey
2016/03/30 23:28:34
Done.
|
| + MockConfigSettings() |