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

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

Issue 2414523002: [Findit] Reorganizing findit_for_*.py (Closed)
Patch Set: rebasing against recently landed cls 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 MOCK_REPOSITORY = None
22
23 class UnsupportedClient(Findit): # pylint: disable=W0223
24 @property
25 def client_id(self):
26 return self._client_id
27
28 def __init__(self, client_id=None):
29 super(UnsupportedClient, self).__init__(MOCK_REPOSITORY, MOCK_PIPELINE_CLS)
30 if client_id is None:
31 client_id = 'unsupported_client'
32 self._client_id = client_id
33
34
35 class FinditTest(CrashTestCase):
36
37 def testPlatformRename(self):
38 class _MockFindit(Findit): # pylint: disable=W0223
39 @classmethod
40 def _ClientID(cls):
41 return CrashClient.FRACAS
42
43 self.assertEqual(
44 _MockFindit(MOCK_REPOSITORY, MOCK_PIPELINE_CLS).RenamePlatform('linux'),
45 'unix')
46
47 # TODO(wrengr): make this test more straightforward/immediate; or give
48 # it a better name.
49 def testScheduleNewAnalysisWithPlatformRename(self):
50 old_crash_data = DummyCrashData(
51 version = None,
52 platform = 'unix',
53 crash_identifiers = {})
54 # This is just here to match the old tests. Shouldn't actually be necessary.
55 del old_crash_data['customized_data']['historical_metadata']
56
57 testcase = self
58 class _MockFindit(Findit): # pylint: disable=W0223
59 def __init__(self):
60 super(_MockFindit, self).__init__(MOCK_REPOSITORY, MOCK_PIPELINE_CLS)
61
62 # TODO(wrengr): coverage tests indicate this mock isn't being called.
63 def _NeedsNewAnalysis(self, new_crash_data):
64 testcase.assertDictEqual(new_crash_data, old_crash_data)
65 return False
66
67 new_crash_data = copy.deepcopy(old_crash_data)
68 new_crash_data['platform'] = 'linux'
69 self.assertFalse(_MockFindit().ScheduleNewAnalysis(new_crash_data))
70
71 def testCheckPolicyUnsupportedClient(self):
72 self.assertIsNone(UnsupportedClient().CheckPolicy(DummyCrashData(
73 platform = 'canary',
74 signature = 'sig',
75 )))
76
77 def testCreateAnalysisForUnsupportedClientId(self):
78 self.assertIsNone(UnsupportedClient('unsupported_id').CreateAnalysis(
79 {'signature': 'sig'}))
80
81 def testGetAnalysisForUnsuportedClient(self):
82 crash_identifiers = {'signature': 'sig'}
83 # TODO(wrengr): it'd be less fragile to call FinditForFracas.CreateAnalysis
84 # instead. But then we'd need to make UnsupportedClient inherit that
85 # implementation, rather than inheriting the one from the Findit
86 # base class.
87 analysis = FracasCrashAnalysis.Create(crash_identifiers)
88 analysis.put()
89 self.assertIsNone(
90 UnsupportedClient('Unsupported_client').GetAnalysis(crash_identifiers),
91 'Unsupported client unexpectedly got analysis %s via identifiers %s'
92 % (analysis, crash_identifiers))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698