| 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 import mock |
| 6 |
| 5 from common import chrome_dependency_fetcher | 7 from common import chrome_dependency_fetcher |
| 6 from common.dependency import DependencyRoll | 8 from common.dependency import DependencyRoll |
| 7 from common.http_client_appengine import HttpClientAppengine | 9 from common.http_client_appengine import HttpClientAppengine |
| 8 from crash import chromecrash_parser | 10 from crash import chromecrash_parser |
| 9 from crash import detect_regression_range | 11 from crash import detect_regression_range |
| 12 from crash import findit |
| 10 from crash import findit_for_chromecrash | 13 from crash import findit_for_chromecrash |
| 11 from crash.changelist_classifier import ChangelistClassifier | 14 from crash.changelist_classifier import ChangelistClassifier |
| 12 from crash.chromecrash_parser import ChromeCrashParser | 15 from crash.chromecrash_parser import ChromeCrashParser |
| 13 from crash.component_classifier import ComponentClassifier | 16 from crash.component_classifier import ComponentClassifier |
| 14 from crash.crash_report import CrashReport | 17 from crash.crash_report import CrashReport |
| 15 from crash.culprit import Culprit | 18 from crash.culprit import Culprit |
| 16 from crash.findit_for_chromecrash import FinditForChromeCrash | 19 from crash.findit_for_chromecrash import FinditForChromeCrash |
| 17 from crash.findit_for_chromecrash import FinditForFracas | 20 from crash.findit_for_chromecrash import FinditForFracas |
| 18 from crash.findit import Findit | |
| 19 from crash.project_classifier import ProjectClassifier | 21 from crash.project_classifier import ProjectClassifier |
| 20 from crash.results import MatchResult | 22 from crash.results import MatchResult |
| 21 from crash.stacktrace import CallStack | 23 from crash.stacktrace import CallStack |
| 22 from crash.stacktrace import Stacktrace | 24 from crash.stacktrace import Stacktrace |
| 23 from crash.test.crash_pipeline_test import DummyCrashData | 25 from crash.test.crash_pipeline_test import DummyCrashData |
| 24 from crash.test.crash_testcase import CrashTestCase | 26 from crash.test.crash_testcase import CrashTestCase |
| 25 from crash.type_enums import CrashClient | 27 from crash.type_enums import CrashClient |
| 26 from lib.gitiles import gitiles_repository | 28 from lib.gitiles import gitiles_repository |
| 27 from model import analysis_status | 29 from model import analysis_status |
| 28 from model.crash.crash_analysis import CrashAnalysis | 30 from model.crash.crash_analysis import CrashAnalysis |
| 29 from model.crash.fracas_crash_analysis import FracasCrashAnalysis | 31 from model.crash.fracas_crash_analysis import FracasCrashAnalysis |
| 30 | 32 |
| 31 MOCK_REPOSITORY = None | 33 MOCK_REPOSITORY = None |
| 32 | 34 |
| 33 class _FinditForChromeCrash(FinditForChromeCrash): | 35 class _FinditForChromeCrash(FinditForChromeCrash): # pylint: disable = W |
| 34 # We allow overriding the default MOCK_REPOSITORY because one unittest | 36 # We allow overriding the default MOCK_REPOSITORY because one unittest |
| 35 # needs to. | 37 # needs to. |
| 36 def __init__(self, repository=MOCK_REPOSITORY): | 38 def __init__(self, repository=MOCK_REPOSITORY): |
| 37 super(_FinditForChromeCrash, self).__init__(repository) | 39 super(_FinditForChromeCrash, self).__init__(repository) |
| 38 | 40 |
| 39 @classmethod | 41 @classmethod |
| 40 def _ClientID(cls): # pragma: no cover | 42 def _ClientID(cls): # pragma: no cover |
| 41 """Avoid throwing a NotImplementedError. | 43 """Avoid throwing a NotImplementedError. |
| 42 | 44 |
| 43 Since this method is called from ``FinditForChromeCrash.__init__`` | 45 Since this method is called from ``FinditForChromeCrash.__init__`` |
| (...skipping 10 matching lines...) Expand all Loading... |
| 54 The default ``Findit.config`` will return None if the client | 56 The default ``Findit.config`` will return None if the client |
| 55 id is not found in the CrashConfig. This in turn will cause | 57 id is not found in the CrashConfig. This in turn will cause |
| 56 ``FinditForChromeCrash.__init__`` to crash, since NoneType doesn't | 58 ``FinditForChromeCrash.__init__`` to crash, since NoneType doesn't |
| 57 have a ``get`` method. In general it's fine for things to crash, since | 59 have a ``get`` method. In general it's fine for things to crash, since |
| 58 noone should make instances of Findit subclasses which don't define | 60 noone should make instances of Findit subclasses which don't define |
| 59 ``_clientID``; but for this test suite, we want to permit instances | 61 ``_clientID``; but for this test suite, we want to permit instances |
| 60 of FinditForChromeCrash, so that we can test that class directly. | 62 of FinditForChromeCrash, so that we can test that class directly. |
| 61 """ | 63 """ |
| 62 return {} | 64 return {} |
| 63 | 65 |
| 66 |
| 64 def _FinditForFracas(): | 67 def _FinditForFracas(): |
| 65 """A helper to pass in the standard pipeline class.""" | 68 """A helper to pass in the standard pipeline class.""" |
| 66 return FinditForFracas(MOCK_REPOSITORY) | 69 return FinditForFracas(MOCK_REPOSITORY) |
| 67 | 70 |
| 68 | 71 |
| 69 class FinditForChromeCrashTest(CrashTestCase): | 72 class FinditForChromeCrashTest(CrashTestCase): |
| 70 | 73 |
| 71 chrome_dep_fetcher = chrome_dependency_fetcher.ChromeDependencyFetcher( | 74 chrome_dep_fetcher = chrome_dependency_fetcher.ChromeDependencyFetcher( |
| 72 gitiles_repository.GitilesRepository(HttpClientAppengine())) | 75 gitiles_repository.GitilesRepository(HttpClientAppengine())) |
| 73 | 76 |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 expected_tag = { | 255 expected_tag = { |
| 253 'found_suspects': False, | 256 'found_suspects': False, |
| 254 'found_project': False, | 257 'found_project': False, |
| 255 'found_components': False, | 258 'found_components': False, |
| 256 'has_regression_range': False, | 259 'has_regression_range': False, |
| 257 'solution': 'core_algorithm', | 260 'solution': 'core_algorithm', |
| 258 } | 261 } |
| 259 | 262 |
| 260 self.assertDictEqual(expected_results, results) | 263 self.assertDictEqual(expected_results, results) |
| 261 self.assertDictEqual(expected_tag, tag) | 264 self.assertDictEqual(expected_tag, tag) |
| 265 |
| 266 @mock.patch('google.appengine.ext.ndb.Key.urlsafe') |
| 267 @mock.patch('common.appengine_util.GetDefaultVersionHostname') |
| 268 def testProcessResultForPublishing(self, mocked_get_default_host, |
| 269 mocked_urlsafe): |
| 270 mocked_host = 'http://host' |
| 271 mocked_get_default_host.return_value = mocked_host |
| 272 urlsafe_key = 'abcde' |
| 273 mocked_urlsafe.return_value = urlsafe_key |
| 274 |
| 275 crash_identifiers = {'signature': 'sig'} |
| 276 analysis = FracasCrashAnalysis.Create(crash_identifiers) |
| 277 analysis.result = {'other': 'data'} |
| 278 findit_object = FinditForFracas(None) |
| 279 expected_processed_result = { |
| 280 'client_id': findit_object.client_id, |
| 281 'crash_identifiers': {'signature': 'sig'}, |
| 282 'result': { |
| 283 'feedback_url': ( |
| 284 findit_for_chromecrash._FRACAS_FEEDBACK_URL_TEMPLATE % ( |
| 285 mocked_host, urlsafe_key)), |
| 286 'other': 'data' |
| 287 } |
| 288 } |
| 289 |
| 290 self.assertDictEqual(findit_object.GetPublishableResult(crash_identifiers, |
| 291 analysis), |
| 292 expected_processed_result) |
| OLD | NEW |