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

Side by Side Diff: appengine/findit/handlers/crash/test/fracas_crash_test.py

Issue 1852383002: [Findit] Integrate with Fracas through Pub/Sub. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Created 4 years, 8 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 unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 import base64
6 import json
7 import os
8 import re
9
10 import webapp2
11 import webtest
12
13 from crash.test.crash_testcase import CrashTestCase
14 from handlers.crash import fracas_crash
15 from model.crash.crash_config import CrashConfig
16
17
18 class FracasCrashTest(CrashTestCase):
19 app_module = webapp2.WSGIApplication([
20 ('/crash/fracas', fracas_crash.FracasCrash),
21 ], debug=True)
22
23 def _MockScheduleNewAnalysisForCrash(self, requested_crashes):
24 def Mocked_ScheduleNewAnalysisForCrash(*crash_data, **_):
25 requested_crashes.append(crash_data)
26 self.mock(fracas_crash.fracas_crash_pipeline, 'ScheduleNewAnalysisForCrash',
27 Mocked_ScheduleNewAnalysisForCrash)
28
29 def testUnauthorizedToken(self):
30 requested_crashes = []
31 self._MockScheduleNewAnalysisForCrash(requested_crashes)
32 self.assertRaisesRegexp(
33 webtest.app.AppError,
34 re.compile('.*403.* Unauthorized access: invalid token.*',
35 re.MULTILINE | re.DOTALL),
36 self.test_app.post, '/crash/fracas?token=UnauthorizedToken')
37 self.assertEqual(0, len(requested_crashes))
38
39 def testAnalysisScheduled(self):
40 requested_crashes = []
41 self._MockScheduleNewAnalysisForCrash(requested_crashes)
42
43 channel = 'supported_channel'
44 platform = 'supported_platform'
45 signature = 'signature/here'
46 stack_trace = 'frame1\nframe2\nframe3'
47 chrome_version = '50.2500.0.0'
48 cpm = [['50.2500.0.0']]
49
50 request_json_data = {
51 'message': {
52 'data': base64.b64encode(json.dumps({
53 'channel': channel,
54 'platform': platform,
55 'signature': signature,
56 'stack_trace': stack_trace,
57 'chrome_version': chrome_version,
58 'cpm': cpm,
59 })),
60 'message_id': 'id',
61 },
62 'subscription': 'subscription',
63 }
64
65 crash_config = CrashConfig.Get()
66 token = crash_config.fracas.get('crash_data_push_token')
67 self.test_app.post_json('/crash/fracas?token=%s' % token, request_json_data)
68
69 self.assertEqual(1, len(requested_crashes))
70 self.assertEqual(
71 (channel, platform, signature, stack_trace, chrome_version, cpm),
72 requested_crashes[0])
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698