Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2590)

Unified Diff: appengine/findit/crash/test/predator_testcase.py

Issue 2673733002: [Predator] Add CrashData class to process raw json crash data. (Closed)
Patch Set: Rebase and fix nits. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « appengine/findit/crash/test/findit_test.py ('k') | appengine/findit/gae_libs/testcase.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/findit/crash/test/predator_testcase.py
diff --git a/appengine/findit/crash/test/predator_testcase.py b/appengine/findit/crash/test/predator_testcase.py
index e977199478bed04b65ea0f86b2869844e16371a6..d8c955b02473b5bd4a9c925a0ef81852e4d56492 100644
--- a/appengine/findit/crash/test/predator_testcase.py
+++ b/appengine/findit/crash/test/predator_testcase.py
@@ -8,10 +8,14 @@ import re
import gae_ts_mon
from google.appengine.api import users
+from crash.crash_data import CrashData
+from crash.findit import Findit
from gae_libs.testcase import TestCase
from libs.gitiles.change_log import ChangeLog
+from libs.gitiles.gitiles_repository import GitilesRepository
from libs.http import retry_http_client
from model.crash.crash_config import CrashConfig
+from model.crash.crash_analysis import CrashAnalysis
DEFAULT_CONFIG_DATA = {
@@ -25,6 +29,16 @@ DEFAULT_CONFIG_DATA = {
'signature_blacklist_markers': ['Blacklist marker'],
'top_n': 7
},
+ 'cracas': {
+ 'analysis_result_pubsub_topic': 'projects/project-name/topics/name',
+ 'supported_platform_list_by_channel': {
+ 'canary': ['win', 'mac', 'linux'],
+ 'supported_channel': ['supported_platform'],
+ },
+ 'platform_rename': {'linux': 'unix'},
+ 'signature_blacklist_markers': ['Blacklist marker'],
+ 'top_n': 7
+ },
'component_classifier': {
'path_function_component': [
[
@@ -82,7 +96,7 @@ DUMMY_CHANGELOG = ChangeLog.FromDict({
-class PredatorTestCase(TestCase): # pragma: no cover.
+class PredatorTestCase(TestCase): # pragma: no cover
def setUp(self):
super(PredatorTestCase, self).setUp()
@@ -92,3 +106,61 @@ class PredatorTestCase(TestCase): # pragma: no cover.
def GetDummyChangeLog(self):
return DUMMY_CHANGELOG
+
+ def GetMockFindit(self, get_repository=None, config=None,
+ client_id='mock_client'):
+ """Gets Mocked ``Findit`` object."""
+ get_repository = (get_repository or
+ GitilesRepository.Factory(self.GetMockHttpClient()))
+ config = config or CrashConfig.Get()
+
+ class MockFindit(Findit): # pylint: disable=W0223
+ """Overwrite abstract method of Findit for testing."""
+ def __init__(self):
+ super(MockFindit, self).__init__(get_repository, config)
+
+ @classmethod
+ def _ClientID(cls):
+ return client_id
+
+ def ProcessResultForPublishing(self, result, key):
+ return result
+
+ def GetAnalysis(self, crash_identifiers):
+ return CrashAnalysis.Get(crash_identifiers)
+
+ def CreateAnalysis(self, crash_identifiers):
+ return CrashAnalysis.Create(crash_identifiers)
+
+ return MockFindit()
+
+ def GetDummyCrashData(self, client_id='mock_client', version='1',
+ signature='signature', platform='win',
+ stack_trace=None, regression_range=None,
+ channel='canary', historical_metadata=None,
+ crash_identifiers=True, process_type='browser'):
+ """Gets Mocked crashed_data sent by clients."""
+ if crash_identifiers is True: # pragma: no cover
+ crash_identifiers = {
+ 'chrome_version': version,
+ 'signature': signature,
+ 'channel': channel,
+ 'platform': platform,
+ 'process_type': process_type,
+ }
+ crash_data = {
+ 'chrome_version': version,
+ 'signature': signature,
+ 'platform': platform,
+ 'stack_trace': stack_trace,
+ 'regression_range': regression_range,
+ 'crash_identifiers': crash_identifiers,
+ 'customized_data': {
+ 'historical_metadata': historical_metadata,
+ 'channel': channel,
+ },
+ }
+ # This insertion of client_id is used for debugging ScheduleNewAnalysis.
+ if client_id is not None: # pragma: no cover
+ crash_data['client_id'] = client_id
+ return crash_data
« no previous file with comments | « appengine/findit/crash/test/findit_test.py ('k') | appengine/findit/gae_libs/testcase.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698