| Index: appengine/findit/crash/test/findit_test.py
|
| diff --git a/appengine/findit/crash/test/findit_test.py b/appengine/findit/crash/test/findit_test.py
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..1f32b36962a264c379b1cf823f4c354f2ee8b49e
|
| --- /dev/null
|
| +++ b/appengine/findit/crash/test/findit_test.py
|
| @@ -0,0 +1,89 @@
|
| +# Copyright 2016 The Chromium Authors. All rights reserved.
|
| +# Use of this source code is governed by a BSD-style license that can be
|
| +# found in the LICENSE file.
|
| +
|
| +import copy
|
| +import logging
|
| +
|
| +from crash.findit import Findit
|
| +from crash.type_enums import CrashClient
|
| +from crash.test.crash_pipeline_test import DummyCrashData
|
| +from crash.test.crash_testcase import CrashTestCase
|
| +from model.crash.fracas_crash_analysis import FracasCrashAnalysis
|
| +
|
| +# In production we'd use CrashWrapperPipeline. And that'd work fine here,
|
| +# since we never actually call the method that uses it. But just to be
|
| +# absolutely sure we don't go over the wire due to some mocking failure,
|
| +# we'll use this dummy class instead. (In fact, since it's never used,
|
| +# we don't even need to give a real class; |None| works just fine.)
|
| +MOCK_PIPELINE_CLS = None
|
| +
|
| +class UnsupportedClient(Findit): # pylint: disable=W0223
|
| + @property
|
| + def client_id(self):
|
| + return self._client_id
|
| +
|
| + def __init__(self, client_id=None):
|
| + super(UnsupportedClient, self).__init__(MOCK_PIPELINE_CLS)
|
| + if client_id is None:
|
| + client_id = 'unsupported_client'
|
| + self._client_id = client_id
|
| +
|
| +
|
| +class FinditTest(CrashTestCase):
|
| +
|
| + def testPlatformRename(self):
|
| + class _MockFindit(Findit): # pylint: disable=W0223
|
| + @classmethod
|
| + def _ClientID(cls):
|
| + return CrashClient.FRACAS
|
| +
|
| + self.assertEqual(_MockFindit(MOCK_PIPELINE_CLS).RenamePlatform('linux'),
|
| + 'unix')
|
| +
|
| + # TODO(wrengr): make this test more straightforward/immediate; or give
|
| + # it a better name.
|
| + def testScheduleNewAnalysisWithPlatformRename(self):
|
| + old_crash_data = DummyCrashData(
|
| + version = None,
|
| + platform = 'unix',
|
| + crash_identifiers = {})
|
| + # This is just here to match the old tests. Shouldn't actually be necessary.
|
| + del old_crash_data['customized_data']['historical_metadata']
|
| +
|
| + testcase = self
|
| + class _MockFindit(Findit): # pylint: disable=W0223
|
| + def __init__(self):
|
| + super(_MockFindit, self).__init__(MOCK_PIPELINE_CLS)
|
| +
|
| + # TODO(wrengr): coverage tests indicate this mock isn't being called.
|
| + def _NeedsNewAnalysis(self, new_crash_data):
|
| + testcase.assertDictEqual(new_crash_data, old_crash_data)
|
| + return False
|
| +
|
| + new_crash_data = copy.deepcopy(old_crash_data)
|
| + new_crash_data['platform'] = 'linux'
|
| + self.assertFalse(_MockFindit().ScheduleNewAnalysis(new_crash_data))
|
| +
|
| + def testCheckPolicyUnsupportedClient(self):
|
| + self.assertIsNone(UnsupportedClient().CheckPolicy(DummyCrashData(
|
| + platform = 'canary',
|
| + signature = 'sig',
|
| + )))
|
| +
|
| + def testCreateAnalysisForUnsupportedClientId(self):
|
| + self.assertIsNone(UnsupportedClient('unsupported_id').CreateAnalysis(
|
| + {'signature': 'sig'}))
|
| +
|
| + def testGetAnalysisForUnsuportedClient(self):
|
| + crash_identifiers = {'signature': 'sig'}
|
| + # TODO(wrengr): it'd be less fragile to call FinditForFracas.CreateAnalysis
|
| + # instead. But then we'd need to make UnsupportedClient inherit that
|
| + # implementation, rather than inheriting the one from the Findit
|
| + # base class.
|
| + analysis = FracasCrashAnalysis.Create(crash_identifiers)
|
| + analysis.put()
|
| + self.assertIsNone(
|
| + UnsupportedClient('Unsupported_client').GetAnalysis(crash_identifiers),
|
| + 'Unsupported client unexpectedly got analysis %s via identifiers %s'
|
| + % (analysis, crash_identifiers))
|
|
|