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

Side by Side Diff: appengine/findit/crash/test/findit_test.py

Issue 2414523002: [Findit] Reorganizing findit_for_*.py (Closed)
Patch Set: Addressing the crash_config.fracas issue Created 4 years, 1 month 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 2016 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 copy
6 import logging
7
8 from crash.findit import Findit
9 from crash.type_enums import CrashClient
10 from crash.test.crash_pipeline_test import DummyCrashData
11 from crash.test.crash_testcase import CrashTestCase
12 from model.crash.fracas_crash_analysis import FracasCrashAnalysis
13
14 # In production we'd use CrashWrapperPipeline. And that'd work fine here,
15 # since we never actually call the method that uses it. But just to be
16 # absolutely sure we don't go over the wire due to some mocking failure,
17 # we'll use this dummy class instead. (In fact, since it's never used,
18 # we don't even need to give a real class; |None| works just fine.)
19 MOCK_PIPELINE_CLS = None
20
21 class UnsupportedClient(Findit): # pylint: disable=W0223
22 @property
23 def client_id(self):
24 return self._client_id
25
26 def __init__(self, client_id=None):
27 super(UnsupportedClient, self).__init__(MOCK_PIPELINE_CLS)
28 if client_id is None:
29 client_id = 'unsupported_client'
30 self._client_id = client_id
31
32
33 class FinditTest(CrashTestCase):
34
35 def testPlatformRename(self):
36 class _MockFindit(Findit): # pylint: disable=W0223
37 @classmethod
38 def _ClientID(cls):
39 return CrashClient.FRACAS
40
41 self.assertEqual(_MockFindit(MOCK_PIPELINE_CLS).RenamePlatform('linux'),
42 'unix')
43
44 # TODO(wrengr): make this test more straightforward/immediate; or give
45 # it a better name.
46 def testScheduleNewAnalysisWithPlatformRename(self):
47 old_crash_data = DummyCrashData(
48 version = None,
49 platform = 'unix',
50 crash_identifiers = {})
51 # This is just here to match the old tests. Shouldn't actually be necessary.
52 del old_crash_data['customized_data']['historical_metadata']
53
54 testcase = self
55 class _MockFindit(Findit): # pylint: disable=W0223
56 def __init__(self):
57 super(_MockFindit, self).__init__(MOCK_PIPELINE_CLS)
58
59 # TODO(wrengr): coverage tests indicate this mock isn't being called.
60 def _NeedsNewAnalysis(self, new_crash_data):
61 testcase.assertDictEqual(new_crash_data, old_crash_data)
62 return False
63
64 new_crash_data = copy.deepcopy(old_crash_data)
65 new_crash_data['platform'] = 'linux'
66 self.assertFalse(_MockFindit().ScheduleNewAnalysis(new_crash_data))
67
68 def testCheckPolicyUnsupportedClient(self):
69 self.assertIsNone(UnsupportedClient().CheckPolicy(DummyCrashData(
70 platform = 'canary',
71 signature = 'sig',
72 )))
73
74 def testCreateAnalysisForUnsupportedClientId(self):
75 self.assertIsNone(UnsupportedClient('unsupported_id').CreateAnalysis(
76 {'signature': 'sig'}))
77
78 def testGetAnalysisForUnsuportedClient(self):
79 crash_identifiers = {'signature': 'sig'}
80 # TODO(wrengr): it'd be less fragile to call FinditForFracas.CreateAnalysis
81 # instead. But then we'd need to make UnsupportedClient inherit that
82 # implementation, rather than inheriting the one from the Findit
83 # base class.
84 analysis = FracasCrashAnalysis.Create(crash_identifiers)
85 analysis.put()
86 self.assertIsNone(
87 UnsupportedClient('Unsupported_client').GetAnalysis(crash_identifiers),
88 'Unsupported client unexpectedly got analysis %s via identifiers %s'
89 % (analysis, crash_identifiers))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698