| 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 import os | 5 import os |
| 6 | 6 |
| 7 from testing_utils import testing | 7 from testing_utils import testing |
| 8 | 8 |
| 9 from lib import time_util | 9 from libs import time_util |
| 10 from libs.http import retry_http_client | 10 from libs.http import retry_http_client |
| 11 | 11 |
| 12 | 12 |
| 13 class MockHttpClient(retry_http_client.RetryHttpClient): # pragma: no cover. | 13 class MockHttpClient(retry_http_client.RetryHttpClient): # pragma: no cover. |
| 14 | 14 |
| 15 def __init__(self, response_for_url=None): | 15 def __init__(self, response_for_url=None): |
| 16 super(MockHttpClient, self).__init__() | 16 super(MockHttpClient, self).__init__() |
| 17 if response_for_url is None: | 17 if response_for_url is None: |
| 18 self.response_for_url = {} | 18 self.response_for_url = {} |
| 19 | 19 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 """Mocks utcnow with the given value for testing.""" | 68 """Mocks utcnow with the given value for testing.""" |
| 69 self.mock(time_util, 'GetUTCNow', lambda: mocked_utcnow) | 69 self.mock(time_util, 'GetUTCNow', lambda: mocked_utcnow) |
| 70 | 70 |
| 71 def MockUTCNowWithTimezone(self, mocked_utcnow): | 71 def MockUTCNowWithTimezone(self, mocked_utcnow): |
| 72 """Mocks utcnow with the given value for testing.""" | 72 """Mocks utcnow with the given value for testing.""" |
| 73 self.mock(time_util, 'GetUTCNowWithTimezone', lambda: mocked_utcnow) | 73 self.mock(time_util, 'GetUTCNowWithTimezone', lambda: mocked_utcnow) |
| 74 | 74 |
| 75 def GetMockHttpClient(self, response_for_url=None): | 75 def GetMockHttpClient(self, response_for_url=None): |
| 76 """Return mocked http client class.""" | 76 """Return mocked http client class.""" |
| 77 return MockHttpClient(response_for_url) | 77 return MockHttpClient(response_for_url) |
| OLD | NEW |