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

Unified Diff: appengine/findit/handlers/crash/test/crash_handler_test.py

Issue 2414523002: [Findit] Reorganizing findit_for_*.py (Closed)
Patch Set: Fixing call to ScheduleNewAnalysis in handlers/crash/crash_handler.py Created 4 years, 2 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
Index: appengine/findit/handlers/crash/test/crash_handler_test.py
diff --git a/appengine/findit/handlers/crash/test/crash_handler_test.py b/appengine/findit/handlers/crash/test/crash_handler_test.py
index 579cd9f00ef9050e10f72fe6757c6f6b0a1667b9..9ed266f7337d08774e67edb307f2a1b156b04db6 100644
--- a/appengine/findit/handlers/crash/test/crash_handler_test.py
+++ b/appengine/findit/handlers/crash/test/crash_handler_test.py
@@ -11,6 +11,7 @@ import webapp2
import webtest
from crash import crash_pipeline
+from crash.findit import Findit
from crash.test.crash_testcase import CrashTestCase
from handlers.crash import crash_handler
@@ -20,15 +21,16 @@ class CrashHandlerTest(CrashTestCase):
('/_ah/push-handlers/crash/fracas', crash_handler.CrashHandler),
], debug=True)
- def _MockScheduleNewAnalysisForCrash(self, requested_crashes):
- def Mocked_ScheduleNewAnalysisForCrash(*crash_data, **_):
- requested_crashes.append(crash_data)
- self.mock(crash_pipeline, 'ScheduleNewAnalysisForCrash',
- Mocked_ScheduleNewAnalysisForCrash)
-
def testAnalysisScheduled(self):
requested_crashes = []
- self._MockScheduleNewAnalysisForCrash(requested_crashes)
+ # TODO(wrengr): the old test mocked the function directly, but since
+ # we moved it to a method that's impossible. So how to we make sure
+ # things get dispatched to this mock? It doesn't look like it was
+ # called from anywhere...
+ class _MockFindit(Findit):
+ def ScheduleNewAnalysis(self, crash_data, **_):
+ requested_crashes.append(crash_data)
+
self.mock_current_user(user_email='test@chromium.org', is_admin=True)
client_id = 'fracas'
@@ -37,7 +39,7 @@ class CrashHandlerTest(CrashTestCase):
signature = 'signature/here'
stack_trace = 'frame1\nframe2\nframe3'
chrome_version = '50.2500.0.0'
- historic_metadata = [{'chrome_version': '50.2500.0.0', 'cpm': 0.6}]
+ historical_metadata = [{'chrome_version': '50.2500.0.0', 'cpm': 0.6}]
crash_identifiers = {
'chrome_version': chrome_version,
@@ -51,26 +53,21 @@ class CrashHandlerTest(CrashTestCase):
'message': {
'data': base64.b64encode(json.dumps({
'customized_data': {
- 'channel': 'supported_channel',
- 'historical_metadata': [
- {
- 'chrome_version': '50.2500.0.0',
- 'cpm': 0.6
- },
- ]
+ 'channel': channel,
+ 'historical_metadata': historical_metadata,
},
- 'chrome_version': '50.2500.0.0',
- 'signature': 'signature/here',
- 'client_id': 'fracas',
- 'platform': 'supported_platform',
+ 'chrome_version': chrome_version,
+ 'signature': signature,
+ 'client_id': client_id,
+ 'platform': platform,
'crash_identifiers': {
- 'chrome_version': '50.2500.0.0',
- 'signature': 'signature/here',
- 'channel': 'supported_channel',
- 'platform': 'supported_platform',
- 'process_type': 'renderer'
+ 'chrome_version': chrome_version,
+ 'signature': signature,
+ 'channel': channel,
+ 'platform': platform,
+ 'process_type': 'renderer',
},
- 'stack_trace': 'frame1\nframe2\nframe3'
+ 'stack_trace': stack_trace,
})),
'message_id': 'id',
},
@@ -84,5 +81,5 @@ class CrashHandlerTest(CrashTestCase):
self.assertEqual(
(crash_identifiers, chrome_version, signature, client_id,
platform, stack_trace, {'channel': channel,
- 'historical_metadata': historic_metadata}),
+ 'historical_metadata': historical_metadata}),
requested_crashes[0])

Powered by Google App Engine
This is Rietveld 408576698