| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 from google.appengine.api import users | 5 from google.appengine.api import users |
| 6 from testing_utils import testing | |
| 7 | 6 |
| 8 import copy | 7 import copy |
| 9 | 8 |
| 9 from common.findit_testcase import FinditTestCase |
| 10 from model.wf_config import FinditConfig | 10 from model.wf_config import FinditConfig |
| 11 | 11 |
| 12 | 12 |
| 13 _DEFAULT_STEPS_FOR_MASTERS_RULES = { | 13 _DEFAULT_STEPS_FOR_MASTERS_RULES = { |
| 14 'supported_masters': { | 14 'supported_masters': { |
| 15 'm': { | 15 'm': { |
| 16 'check_global': True | 16 'check_global': True |
| 17 }, | 17 }, |
| 18 'm3': { | 18 'm3': { |
| 19 'check_global': True | 19 'check_global': True |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 | 80 |
| 81 | 81 |
| 82 DEFAULT_CONFIG_DATA = { | 82 DEFAULT_CONFIG_DATA = { |
| 83 'steps_for_masters_rules': _DEFAULT_STEPS_FOR_MASTERS_RULES, | 83 'steps_for_masters_rules': _DEFAULT_STEPS_FOR_MASTERS_RULES, |
| 84 'builders_to_trybots': _DEFAULT_TRY_BOT_MAPPING, | 84 'builders_to_trybots': _DEFAULT_TRY_BOT_MAPPING, |
| 85 'try_job_settings': _DEFAULT_TRY_JOB_SETTINGS, | 85 'try_job_settings': _DEFAULT_TRY_JOB_SETTINGS, |
| 86 'swarming_settings': _DEFAULT_SWARMING_SETTINGS | 86 'swarming_settings': _DEFAULT_SWARMING_SETTINGS |
| 87 } | 87 } |
| 88 | 88 |
| 89 | 89 |
| 90 class WaterfallTestCase(testing.AppengineTestCase): # pragma: no cover. | 90 class WaterfallTestCase(FinditTestCase): # pragma: no cover. |
| 91 | 91 |
| 92 def UpdateUnitTestConfigSettings(self, config_property=None, | 92 def UpdateUnitTestConfigSettings(self, config_property=None, |
| 93 override_data=None): | 93 override_data=None): |
| 94 """Sets up Findit's config for unit tests. | 94 """Sets up Findit's config for unit tests. |
| 95 | 95 |
| 96 Args: | 96 Args: |
| 97 config_property: The name of the config property to update. | 97 config_property: The name of the config property to update. |
| 98 override_data: A dict to override any default settings. | 98 override_data: A dict to override any default settings. |
| 99 """ | 99 """ |
| 100 config_data = DEFAULT_CONFIG_DATA | 100 config_data = DEFAULT_CONFIG_DATA |
| 101 | 101 |
| 102 if config_property and override_data: | 102 if config_property and override_data: |
| 103 config_data = copy.deepcopy(DEFAULT_CONFIG_DATA) | 103 config_data = copy.deepcopy(DEFAULT_CONFIG_DATA) |
| 104 config_data[config_property].update(override_data) | 104 config_data[config_property].update(override_data) |
| 105 | 105 |
| 106 FinditConfig.Get().Update(users.User(email='admin@chromium.org'), True, | 106 FinditConfig.Get().Update(users.User(email='admin@chromium.org'), True, |
| 107 **config_data) | 107 **config_data) |
| 108 | 108 |
| 109 def setUp(self): | 109 def setUp(self): |
| 110 super(WaterfallTestCase, self).setUp() | 110 super(WaterfallTestCase, self).setUp() |
| 111 self.UpdateUnitTestConfigSettings() | 111 self.UpdateUnitTestConfigSettings() |
| 112 | 112 |
| 113 | 113 |
| OLD | NEW |