| OLD | NEW |
| (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 import calendar |
| 5 import base64 |
| 6 import copy |
| 7 from datetime import datetime |
| 8 from datetime import time |
| 9 from datetime import timedelta |
| 10 import json |
| 11 |
| 12 from google.appengine.api import users |
| 13 import webapp2 |
| 14 |
| 15 from testing_utils import testing |
| 16 |
| 17 from common import time_util |
| 18 from handlers.crash import fracas_result_feedback |
| 19 from model import analysis_status |
| 20 from model import result_status |
| 21 from model import triage_status |
| 22 from model.crash.fracas_crash_analysis import FracasCrashAnalysis |
| 23 |
| 24 |
| 25 class FracasResultFeedbackTest(testing.AppengineTestCase): |
| 26 app_module = webapp2.WSGIApplication( |
| 27 [('/fracas-result-feedback', |
| 28 fracas_result_feedback.FracasResultFeedback)], debug=True) |
| 29 |
| 30 def setUp(self): |
| 31 super(FracasResultFeedbackTest, self).setUp() |
| 32 analysis = FracasCrashAnalysis.Create({'signature': 'signature'}) |
| 33 analysis.signature = 'signature' |
| 34 analysis.crashed_version = '53.0.2750.0' |
| 35 analysis.stack_trace = 'dummy\nframe1\nframe2' |
| 36 analysis.platform = 'android' |
| 37 analysis.channel = 'canary' |
| 38 analysis.client_id = 'fracas' |
| 39 analysis.status = analysis_status.COMPLETED |
| 40 analysis.historical_metadata = [ |
| 41 {'chrome_version': '53.0.2748.0', 'cpm': 0}, |
| 42 {'chrome_version': '53.0.2749.0', 'cpm': 0}, |
| 43 {'chrome_version': '53.0.2750.0', 'cpm': 0.8} |
| 44 ] |
| 45 |
| 46 suspected_cl = { |
| 47 'url': 'https://chromium.googlesource.com/chromium/src/+/346a', |
| 48 'review_url': 'https://review', |
| 49 'revision': '346a', |
| 50 'project_path': 'src/', |
| 51 'author': 'a@chromium.org', |
| 52 'time': '2016-06-04 00:00:00 UTC', |
| 53 'reason': 'some reason', |
| 54 'confidence': 1 |
| 55 } |
| 56 analysis.result = {'found': True, |
| 57 'suspected_cls': [suspected_cl], |
| 58 'suspected_components': ['Blink>API', 'Blink>DOM'], |
| 59 'suspected_project': 'chromium', |
| 60 'regression_range': ['53.0.2749.0', '53.0.2750.0']} |
| 61 analysis.found_suspects = True |
| 62 analysis.note = 'This is a note.' |
| 63 analysis.put() |
| 64 |
| 65 self.analysis = analysis |
| 66 |
| 67 def testFracasDashBoardHandler(self): |
| 68 response = self.test_app.get('/fracas-result-feedback?key=%s' % |
| 69 self.analysis.key.urlsafe()) |
| 70 self.assertEqual(200, response.status_int) |
| 71 |
| 72 def _GenerateDisplayData(self): |
| 73 analysis = self.analysis |
| 74 return { |
| 75 'signature': analysis.signature, |
| 76 'version': analysis.crashed_version, |
| 77 'channel': analysis.channel, |
| 78 'platform': analysis.platform, |
| 79 'regression_range': ( |
| 80 analysis.result['regression_range'] if 'regression_range' in |
| 81 analysis.result else None), |
| 82 'historical_metadata': analysis.historical_metadata, |
| 83 'stack_trace': analysis.stack_trace, |
| 84 'suspected_cls': ( |
| 85 analysis.result['suspected_cls'] if 'suspected_cls' in |
| 86 analysis.result else None), |
| 87 'suspected_project': ( |
| 88 analysis.result['suspected_project'] if 'suspected_project' in |
| 89 analysis.result else None), |
| 90 'suspected_components': ( |
| 91 analysis.result['suspected_components'] if 'suspected_components' |
| 92 in analysis.result else None), |
| 93 'request_time': time_util.FormatDatetime(analysis.requested_time), |
| 94 'analysis_completed': analysis.completed, |
| 95 'analysis_failed': analysis.failed, |
| 96 } |
| 97 |
| 98 def testDisplayAnanlysisResult(self): |
| 99 expected_result = self._GenerateDisplayData() |
| 100 response_json = self.test_app.get('/fracas-result-feedback?format=json&' |
| 101 'key=%s' % self.analysis.key.urlsafe()) |
| 102 self.assertEqual(200, response_json.status_int) |
| 103 self.assertEqual(expected_result, response_json.json_body) |
| OLD | NEW |