Chromium Code Reviews| Index: appengine/findit/crash/test/crash_testcase.py |
| diff --git a/appengine/findit/crash/test/crash_testcase.py b/appengine/findit/crash/test/crash_testcase.py |
| index e8ac6cd60c18652ea043407bb4df3e3f5843c5e9..0dccd1eff2abfa47bd4c30b5d6a6b27f839f73b5 100644 |
| --- a/appengine/findit/crash/test/crash_testcase.py |
| +++ b/appengine/findit/crash/test/crash_testcase.py |
| @@ -8,6 +8,7 @@ import re |
| from google.appengine.api import users |
| from common.findit_testcase import FinditTestCase |
| +from common import retry_http_client |
| from lib.gitiles.change_log import ChangeLog |
| from model.crash.crash_config import CrashConfig |
| @@ -81,12 +82,33 @@ DUMMY_CHANGELOG = ChangeLog.FromDict({ |
| }) |
| +class MockHttpClient(retry_http_client.RetryHttpClient): # pragma: no cover. |
| + |
| + def __init__(self): |
| + super(MockHttpClient, self).__init__() |
| + |
| + def _Get(self, url, *_): |
| + pass |
| + |
| + def _Post(self, *_): |
| + pass |
| + |
| + def _Put(self, *_): |
| + pass |
| + |
| + |
| class CrashTestCase(FinditTestCase): # pragma: no cover. |
| def setUp(self): |
| super(CrashTestCase, self).setUp() |
| CrashConfig.Get().Update( |
| users.User(email='admin@chromium.org'), True, **DEFAULT_CONFIG_DATA) |
| + # A fake repository, needed by the Findit constructor. We should never |
| + # go over the wire (e.g., in the call to ScheduleNewAnalysis below), |
| + # and this helps ensure that. |
|
stgao
2016/11/14 21:34:12
what's this for?
Sharu Jiang
2016/11/15 02:21:47
This was accidentally pasted... deleted in followi
|
| def GetDummyChangeLog(self): |
| return DUMMY_CHANGELOG |
| + |
| + def GetMockHttpClient(self): |
| + return MockHttpClient() |
|
stgao
2016/11/14 21:34:12
Why not just use a unittest.mock.Mock object?
Sharu Jiang
2016/11/15 02:21:47
I think it's better that MockHttpClient is a insta
stgao
2016/11/17 05:03:05
Why it is better? What's the benefit? Why a unitte
|