| 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 from datetime import datetime | 5 from datetime import datetime |
| 6 import mock |
| 6 | 7 |
| 7 from crash.test.crash_testcase import CrashTestCase | 8 from crash.test.crash_testcase import CrashTestCase |
| 8 from model import analysis_status | 9 from model import analysis_status |
| 9 from model import result_status | 10 from model import result_status |
| 10 from model.crash.fracas_crash_analysis import FracasCrashAnalysis | 11 from model.crash import fracas_crash_analysis |
| 11 | 12 |
| 12 | 13 |
| 13 class FracasCrashAnalysisTest(CrashTestCase): | 14 class FracasCrashAnalysisTest(CrashTestCase): |
| 14 | 15 |
| 15 def testDoNotUseIdentifiersToSetProperties(self): | 16 def testDoNotUseIdentifiersToSetProperties(self): |
| 16 crash_identifiers = { | 17 crash_identifiers = { |
| 17 'chrome_version': '1', | 18 'chrome_version': '1', |
| 18 'signature': 'signature/here', | 19 'signature': 'signature/here', |
| 19 'channel': 'canary', | 20 'channel': 'canary', |
| 20 'platform': 'win', | 21 'platform': 'win', |
| 21 'process_type': 'browser', | 22 'process_type': 'browser', |
| 22 } | 23 } |
| 23 FracasCrashAnalysis.Create(crash_identifiers).put() | 24 fracas_crash_analysis.FracasCrashAnalysis.Create(crash_identifiers).put() |
| 24 analysis = FracasCrashAnalysis.Get(crash_identifiers) | 25 analysis = fracas_crash_analysis.FracasCrashAnalysis.Get(crash_identifiers) |
| 25 self.assertIsNone(analysis.crashed_version) | 26 self.assertIsNone(analysis.crashed_version) |
| 26 self.assertIsNone(analysis.signature) | 27 self.assertIsNone(analysis.signature) |
| 27 self.assertIsNone(analysis.channel) | 28 self.assertIsNone(analysis.channel) |
| 28 self.assertIsNone(analysis.platform) | 29 self.assertIsNone(analysis.platform) |
| 30 |
| 31 @mock.patch('google.appengine.ext.ndb.Key.urlsafe') |
| 32 @mock.patch('common.appengine_util.GetDefaultVersionHostname') |
| 33 def testProcessResultForPublishing(self, mocked_get_default_host, |
| 34 mocked_urlsafe): |
| 35 mocked_host = 'http://host' |
| 36 mocked_get_default_host.return_value = mocked_host |
| 37 urlsafe_key = 'abcde' |
| 38 mocked_urlsafe.return_value = urlsafe_key |
| 39 |
| 40 analysis = fracas_crash_analysis.FracasCrashAnalysis.Create( |
| 41 {'signature': 'sig'}) |
| 42 result = {'other': 'data'} |
| 43 expected_processed_result = { |
| 44 'other': 'data', |
| 45 'feedback_url': fracas_crash_analysis.FRACAS_FEEDBACK_URL_TEMPLATE % ( |
| 46 mocked_host, urlsafe_key) |
| 47 } |
| 48 self.assertDictEqual(analysis.ProcessResultForPublishing(result), |
| 49 expected_processed_result) |
| OLD | NEW |