| 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 import gae_ts_mon | 8 import gae_ts_mon |
| 9 from google.appengine.api import users | 9 from google.appengine.api import users |
| 10 | 10 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 super(PredatorTestCase, self).setUp() | 102 super(PredatorTestCase, self).setUp() |
| 103 CrashConfig.Get().Update( | 103 CrashConfig.Get().Update( |
| 104 users.User(email='admin@chromium.org'), True, **DEFAULT_CONFIG_DATA) | 104 users.User(email='admin@chromium.org'), True, **DEFAULT_CONFIG_DATA) |
| 105 gae_ts_mon.reset_for_unittest(disable=True) | 105 gae_ts_mon.reset_for_unittest(disable=True) |
| 106 | 106 |
| 107 def GetDummyChangeLog(self): | 107 def GetDummyChangeLog(self): |
| 108 return DUMMY_CHANGELOG | 108 return DUMMY_CHANGELOG |
| 109 | 109 |
| 110 def GetMockFindit(self, get_repository=None, config=None, | 110 def GetMockFindit(self, get_repository=None, config=None, |
| 111 client_id='mock_client'): | 111 client_id='mock_client'): |
| 112 """Gets Mocked ``Findit`` object.""" | |
| 113 get_repository = (get_repository or | 112 get_repository = (get_repository or |
| 114 GitilesRepository.Factory(self.GetMockHttpClient())) | 113 GitilesRepository.Factory(self.GetMockHttpClient())) |
| 115 config = config or CrashConfig.Get() | 114 config = config or CrashConfig.Get() |
| 116 | 115 |
| 117 class MockFindit(Findit): # pylint: disable=W0223 | 116 class MockFindit(Findit): # pylint: disable=W0223 |
| 118 """Overwrite abstract method of Findit for testing.""" | 117 """Overwrite abstract method of Findit for testing.""" |
| 119 def __init__(self): | 118 def __init__(self): |
| 120 super(MockFindit, self).__init__(get_repository, config) | 119 super(MockFindit, self).__init__(get_repository, config) |
| 121 | 120 |
| 122 @classmethod | 121 @classmethod |
| 123 def _ClientID(cls): | 122 def _ClientID(cls): |
| 124 return client_id | 123 return client_id |
| 125 | 124 |
| 126 def ProcessResultForPublishing(self, result, key): | 125 def ProcessResultForPublishing(self, result, key): |
| 127 return result | 126 return result |
| 128 | 127 |
| 128 def GetCrashData(self, crash_data): |
| 129 |
| 130 class MockCrashData(CrashData): |
| 131 @property |
| 132 def regression_range(self): |
| 133 return crash_data.get('regression_range') |
| 134 |
| 135 @property |
| 136 def stacktrace(self): |
| 137 return None |
| 138 |
| 139 @property |
| 140 def dependencies(self): |
| 141 return {} |
| 142 |
| 143 @property |
| 144 def dependency_rolls(self): |
| 145 return {} |
| 146 |
| 147 return MockCrashData(crash_data) |
| 148 |
| 129 def GetAnalysis(self, crash_identifiers): | 149 def GetAnalysis(self, crash_identifiers): |
| 130 return CrashAnalysis.Get(crash_identifiers) | 150 return CrashAnalysis.Get(crash_identifiers) |
| 131 | 151 |
| 132 def CreateAnalysis(self, crash_identifiers): | 152 def CreateAnalysis(self, crash_identifiers): |
| 133 return CrashAnalysis.Create(crash_identifiers) | 153 return CrashAnalysis.Create(crash_identifiers) |
| 134 | 154 |
| 135 return MockFindit() | 155 return MockFindit() |
| 136 | 156 |
| 137 def GetDummyCrashData(self, client_id='mock_client', version='1', | 157 def GetDummyChromeCrashData( |
| 138 signature='signature', platform='win', | 158 self, client_id='mock_client', version='1', signature='signature', |
| 139 stack_trace=None, regression_range=None, | 159 platform='win', stack_trace=None, regression_range=None, channel='canary', |
| 140 channel='canary', historical_metadata=None, | 160 historical_metadata=None, process_type='browser'): |
| 141 crash_identifiers=True, process_type='browser'): | 161 crash_identifiers = { |
| 142 """Gets Mocked crashed_data sent by clients.""" | 162 'chrome_version': version, |
| 143 if crash_identifiers is True: # pragma: no cover | 163 'signature': signature, |
| 144 crash_identifiers = { | 164 'channel': channel, |
| 145 'chrome_version': version, | 165 'platform': platform, |
| 146 'signature': signature, | 166 'process_type': process_type, |
| 147 'channel': channel, | 167 } |
| 148 'platform': platform, | 168 customized_data = { |
| 149 'process_type': process_type, | 169 'historical_metadata': historical_metadata, |
| 150 } | 170 'channel': channel, |
| 171 } |
| 172 |
| 151 crash_data = { | 173 crash_data = { |
| 152 'chrome_version': version, | 174 'chrome_version': version, |
| 153 'signature': signature, | 175 'signature': signature, |
| 154 'platform': platform, | 176 'platform': platform, |
| 155 'stack_trace': stack_trace, | 177 'stack_trace': stack_trace, |
| 156 'regression_range': regression_range, | 178 'regression_range': regression_range, |
| 157 'crash_identifiers': crash_identifiers, | 179 'crash_identifiers': crash_identifiers, |
| 158 'customized_data': { | 180 'customized_data': customized_data |
| 159 'historical_metadata': historical_metadata, | |
| 160 'channel': channel, | |
| 161 }, | |
| 162 } | 181 } |
| 163 # This insertion of client_id is used for debugging ScheduleNewAnalysis. | 182 # This insertion of client_id is used for debugging ScheduleNewAnalysis. |
| 164 if client_id is not None: # pragma: no cover | 183 if client_id is not None: # pragma: no cover |
| 165 crash_data['client_id'] = client_id | 184 crash_data['client_id'] = client_id |
| 166 return crash_data | 185 return crash_data |
| OLD | NEW |