Chromium Code Reviews| 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 copy | 5 import copy |
| 6 import re | 6 import re |
| 7 | 7 |
| 8 from google.appengine.api import users | 8 from google.appengine.api import users |
| 9 | 9 |
| 10 from common.findit_testcase import FinditTestCase | 10 from common.findit_testcase import FinditTestCase |
| 11 from common import retry_http_client | |
| 11 from lib.gitiles.change_log import ChangeLog | 12 from lib.gitiles.change_log import ChangeLog |
| 12 from model.crash.crash_config import CrashConfig | 13 from model.crash.crash_config import CrashConfig |
| 13 | 14 |
| 14 | 15 |
| 15 DEFAULT_CONFIG_DATA = { | 16 DEFAULT_CONFIG_DATA = { |
| 16 'fracas': { | 17 'fracas': { |
| 17 'analysis_result_pubsub_topic': 'projects/project-name/topics/name', | 18 'analysis_result_pubsub_topic': 'projects/project-name/topics/name', |
| 18 'supported_platform_list_by_channel': { | 19 'supported_platform_list_by_channel': { |
| 19 'canary': ['win', 'mac', 'linux'], | 20 'canary': ['win', 'mac', 'linux'], |
| 20 'supported_channel': ['supported_platform'], | 21 'supported_channel': ['supported_platform'], |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 74 'committer_time': 'Thu Mar 31 21:28:39 2016', | 75 'committer_time': 'Thu Mar 31 21:28:39 2016', |
| 75 'commit_url': | 76 'commit_url': |
| 76 'https://repo.test/+/1', | 77 'https://repo.test/+/1', |
| 77 'code_review_url': 'https://codereview.chromium.org/3281', | 78 'code_review_url': 'https://codereview.chromium.org/3281', |
| 78 'committer_name': 'example@chromium.org', | 79 'committer_name': 'example@chromium.org', |
| 79 'revision': '1', | 80 'revision': '1', |
| 80 'reverted_revision': None | 81 'reverted_revision': None |
| 81 }) | 82 }) |
| 82 | 83 |
| 83 | 84 |
| 85 class MockHttpClient(retry_http_client.RetryHttpClient): # pragma: no cover. | |
| 86 | |
| 87 def __init__(self): | |
| 88 super(MockHttpClient, self).__init__() | |
| 89 | |
| 90 def _Get(self, url, *_): | |
| 91 pass | |
| 92 | |
| 93 def _Post(self, *_): | |
| 94 pass | |
| 95 | |
| 96 def _Put(self, *_): | |
| 97 pass | |
| 98 | |
| 99 | |
| 84 class CrashTestCase(FinditTestCase): # pragma: no cover. | 100 class CrashTestCase(FinditTestCase): # pragma: no cover. |
| 85 | 101 |
| 86 def setUp(self): | 102 def setUp(self): |
| 87 super(CrashTestCase, self).setUp() | 103 super(CrashTestCase, self).setUp() |
| 88 CrashConfig.Get().Update( | 104 CrashConfig.Get().Update( |
| 89 users.User(email='admin@chromium.org'), True, **DEFAULT_CONFIG_DATA) | 105 users.User(email='admin@chromium.org'), True, **DEFAULT_CONFIG_DATA) |
| 106 # A fake repository, needed by the Findit constructor. We should never | |
| 107 # go over the wire (e.g., in the call to ScheduleNewAnalysis below), | |
| 108 # 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
| |
| 90 | 109 |
| 91 def GetDummyChangeLog(self): | 110 def GetDummyChangeLog(self): |
| 92 return DUMMY_CHANGELOG | 111 return DUMMY_CHANGELOG |
| 112 | |
| 113 def GetMockHttpClient(self): | |
| 114 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
| |
| OLD | NEW |