| 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 import collections | 5 import collections |
| 6 import json | 6 import json |
| 7 import os | 7 import os |
| 8 import requests | 8 import requests |
| 9 import simplejson | 9 import simplejson |
| 10 import subprocess | 10 import subprocess |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 self.res = self.Response( | 140 self.res = self.Response( |
| 141 status_code=200, | 141 status_code=200, |
| 142 json=raiser) | 142 json=raiser) |
| 143 self.mock(requests, 'get', self.requests_handler) | 143 self.mock(requests, 'get', self.requests_handler) |
| 144 self.assertFalse(master.get_accepting_builds(self.chromium_fyi)) | 144 self.assertFalse(master.get_accepting_builds(self.chromium_fyi)) |
| 145 | 145 |
| 146 def testTimeout(self): | 146 def testTimeout(self): |
| 147 def timeout(*_args, **_kwargs): | 147 def timeout(*_args, **_kwargs): |
| 148 raise requests.exceptions.Timeout('timeout') | 148 raise requests.exceptions.Timeout('timeout') |
| 149 self.mock(requests, 'get', timeout) | 149 self.mock(requests, 'get', timeout) |
| 150 self.assertFalse(master.get_accepting_builds(self.chromium_fyi)) | 150 self.assertIsNone(master.get_accepting_builds(self.chromium_fyi)) |
| 151 |
| 152 def testConnectionErr(self): |
| 153 def timeout(*_args, **_kwargs): |
| 154 raise requests.exceptions.ConnectionError('error') |
| 155 self.mock(requests, 'get', timeout) |
| 156 self.assertIsNone(master.get_accepting_builds(self.chromium_fyi)) |
| 151 | 157 |
| 152 class TestMasterManipulation(auto_stub.TestCase): | 158 class TestMasterManipulation(auto_stub.TestCase): |
| 153 def setUp(self): | 159 def setUp(self): |
| 154 super(TestMasterManipulation, self).setUp() | 160 super(TestMasterManipulation, self).setUp() |
| 155 self.chromium_fyi = os.path.join(DATA_DIR, 'master.chromium.fyi') | 161 self.chromium_fyi = os.path.join(DATA_DIR, 'master.chromium.fyi') |
| 156 | 162 |
| 157 def testWithGclientSyncEnabled(self): | 163 def testWithGclientSyncEnabled(self): |
| 158 actions = list(master.convert_action_items_to_cli(( | 164 actions = list(master.convert_action_items_to_cli(( |
| 159 master.GclientSync, | 165 master.GclientSync, |
| 160 master.MakeStop, | 166 master.MakeStop, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 183 self.assertEquals( | 189 self.assertEquals( |
| 184 [a['cmd'] for a in actions], | 190 [a['cmd'] for a in actions], |
| 185 [ | 191 [ |
| 186 ['make', 'stop'], | 192 ['make', 'stop'], |
| 187 ], | 193 ], |
| 188 ) | 194 ) |
| 189 | 195 |
| 190 def testInvalid(self): | 196 def testInvalid(self): |
| 191 with self.assertRaises(ValueError): | 197 with self.assertRaises(ValueError): |
| 192 list(master.convert_action_items_to_cli((-100,), self.chromium_fyi)) | 198 list(master.convert_action_items_to_cli((-100,), self.chromium_fyi)) |
| OLD | NEW |