| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 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 testing_utils import testing | 5 from testing_utils import testing |
| 6 | 6 |
| 7 from model import wf_config | 7 from model.wf_config import FinditConfig |
| 8 from waterfall import waterfall_config | 8 from waterfall import waterfall_config |
| 9 | 9 |
| 10 | 10 |
| 11 | 11 |
| 12 class MastersTest(testing.AppengineTestCase): | 12 class MastersTest(testing.AppengineTestCase): |
| 13 | 13 |
| 14 def setUp(self): | 14 def setUp(self): |
| 15 super(MastersTest, self).setUp() | 15 super(MastersTest, self).setUp() |
| 16 self.mock_current_user(user_email='test@chromium.org', is_admin=True) |
| 16 | 17 |
| 17 class MockSettings(): | 18 config_data = { |
| 18 masters_to_blacklisted_steps = { | 19 'masters_to_blacklisted_steps': { |
| 19 'master1': ['step1', 'step2', 'step3'], | 20 'master1': ['step1', 'step2', 'step3'], |
| 20 'master2': ['step4', 'step5', 'step6'] | 21 'master2': ['step4', 'step5', 'step6'] |
| 21 } | 22 }, |
| 22 builders_to_trybots = { | 23 'builders_to_trybots': { |
| 23 'master1': { | 24 'master1': { |
| 24 'builder1': { | 25 'builder1': { |
| 25 'mastername': 'tryserver1', | 26 'mastername': 'tryserver1', |
| 26 'buildername': 'trybot1', | 27 'buildername': 'trybot1', |
| 27 } | 28 } |
| 28 } | 29 } |
| 29 } | 30 } |
| 31 } |
| 30 | 32 |
| 31 self.mock(wf_config, 'Settings', MockSettings) | 33 FinditConfig.Get().Update(**config_data) |
| 34 |
| 32 | 35 |
| 33 def testMasterIsSupported(self): | 36 def testMasterIsSupported(self): |
| 34 self.assertTrue(waterfall_config.MasterIsSupported('master1')) | 37 self.assertTrue(waterfall_config.MasterIsSupported('master1')) |
| 35 self.assertFalse(waterfall_config.MasterIsSupported('blabla')) | 38 self.assertFalse(waterfall_config.MasterIsSupported('blabla')) |
| 36 | 39 |
| 37 def testStepIsSupportedForMaster(self): | 40 def testStepIsSupportedForMaster(self): |
| 38 self.assertFalse( | 41 self.assertFalse( |
| 39 waterfall_config.StepIsSupportedForMaster('step1', 'master1')) | 42 waterfall_config.StepIsSupportedForMaster('step1', 'master1')) |
| 40 self.assertTrue( | 43 self.assertTrue( |
| 41 waterfall_config.StepIsSupportedForMaster('step4', 'master1')) | 44 waterfall_config.StepIsSupportedForMaster('step4', 'master1')) |
| 42 self.assertFalse( | 45 self.assertFalse( |
| 43 waterfall_config.StepIsSupportedForMaster('blabla', 'blabla')) | 46 waterfall_config.StepIsSupportedForMaster('blabla', 'blabla')) |
| 44 | 47 |
| 45 def testGetTrybotForWaterfallBuilder(self): | 48 def testGetTrybotForWaterfallBuilder(self): |
| 46 self.assertEqual( | 49 self.assertEqual( |
| 47 ('tryserver1', 'trybot1'), | 50 ('tryserver1', 'trybot1'), |
| 48 waterfall_config.GetTrybotForWaterfallBuilder('master1', 'builder1')) | 51 waterfall_config.GetTrybotForWaterfallBuilder('master1', 'builder1')) |
| 49 self.assertEqual( | 52 self.assertEqual( |
| 50 (None, None), | 53 (None, None), |
| 51 waterfall_config.GetTrybotForWaterfallBuilder('master2', 'builder2')) | 54 waterfall_config.GetTrybotForWaterfallBuilder('master2', 'builder2')) |
| OLD | NEW |