| OLD | NEW |
| 1 # Copyright 2014 The LUCI Authors. All rights reserved. | 1 # Copyright 2014 The LUCI Authors. All rights reserved. |
| 2 # Use of this source code is governed under the Apache License, Version 2.0 | 2 # Use of this source code is governed under the Apache License, Version 2.0 |
| 3 # that can be found in the LICENSE file. | 3 # that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import logging | 5 import logging |
| 6 import os | 6 import os |
| 7 import sys | 7 import sys |
| 8 import threading | 8 import threading |
| 9 | 9 |
| 10 TEST_DIR = os.path.dirname(os.path.abspath(__file__)) | 10 TEST_DIR = os.path.dirname(os.path.abspath( |
| 11 __file__.decode(sys.getfilesystemencoding()))) |
| 11 ROOT_DIR = os.path.dirname(TEST_DIR) | 12 ROOT_DIR = os.path.dirname(TEST_DIR) |
| 12 sys.path.insert(0, ROOT_DIR) | 13 sys.path.insert(0, ROOT_DIR) |
| 13 sys.path.insert(0, os.path.join(ROOT_DIR, 'third_party')) | 14 sys.path.insert(0, os.path.join(ROOT_DIR, 'third_party')) |
| 14 | 15 |
| 15 from depot_tools import auto_stub | 16 from depot_tools import auto_stub |
| 16 from utils import net | 17 from utils import net |
| 17 | 18 |
| 18 | 19 |
| 19 def make_fake_response(content, url, headers=None): | 20 def make_fake_response(content, url, headers=None): |
| 20 """Returns HttpResponse with predefined content, useful in tests.""" | 21 """Returns HttpResponse with predefined content, useful in tests.""" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 self.fail('Expected json request, got normal data; %s' % url) | 107 self.fail('Expected json request, got normal data; %s' % url) |
| 107 _, expected_kwargs, result = data | 108 _, expected_kwargs, result = data |
| 108 if callable(expected_kwargs): | 109 if callable(expected_kwargs): |
| 109 expected_kwargs(kwargs) | 110 expected_kwargs(kwargs) |
| 110 else: | 111 else: |
| 111 self.assertEqual(expected_kwargs, kwargs) | 112 self.assertEqual(expected_kwargs, kwargs) |
| 112 if result is not None: | 113 if result is not None: |
| 113 return result | 114 return result |
| 114 return None | 115 return None |
| 115 self.fail('Unknown request %s %s' % (url, kwargs)) | 116 self.fail('Unknown request %s %s' % (url, kwargs)) |
| OLD | NEW |