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 copy | 5 import copy |
6 import logging | 6 import logging |
7 | 7 |
8 from google.appengine.api import app_identity | 8 from google.appengine.api import app_identity |
9 | 9 |
10 from crash.findit import Findit | 10 from crash.findit import Findit |
11 from crash.type_enums import CrashClient | 11 from crash.type_enums import CrashClient |
12 from crash.test.crash_pipeline_test import DummyCrashData | 12 from crash.test.crash_pipeline_test import DummyCrashData |
13 from crash.test.predator_testcase import PredatorTestCase | 13 from crash.test.predator_testcase import PredatorTestCase |
14 from model.crash.fracas_crash_analysis import FracasCrashAnalysis | 14 from model.crash.fracas_crash_analysis import FracasCrashAnalysis |
15 | 15 |
16 MOCK_REPOSITORY = None | 16 |
| 17 MOCK_GET_REPOSITORY = lambda _: None # pragma: no cover |
| 18 |
17 | 19 |
18 class UnsupportedClient(Findit): # pylint: disable=W0223 | 20 class UnsupportedClient(Findit): # pylint: disable=W0223 |
19 # TODO(http://crbug.com/659346): this isn't being called for some reason. | 21 # TODO(http://crbug.com/659346): this isn't being called for some reason. |
20 @property | 22 @property |
21 def client_id(self): # pragma: no cover | 23 def client_id(self): # pragma: no cover |
22 return self._client_id | 24 return self._client_id |
23 | 25 |
24 @property | 26 @property |
25 def config(self): # pragma: no cover | 27 def config(self): # pragma: no cover |
26 """Don't return None, so that PlatformRename doesn't crash.""" | 28 """Don't return None, so that PlatformRename doesn't crash.""" |
27 return {} | 29 return {} |
28 | 30 |
29 def __init__(self, client_id=None): | 31 def __init__(self, client_id=None): |
30 super(UnsupportedClient, self).__init__(MOCK_REPOSITORY) | 32 super(UnsupportedClient, self).__init__(MOCK_GET_REPOSITORY) |
31 if client_id is None: | 33 if client_id is None: |
32 client_id = 'unsupported_client' | 34 client_id = 'unsupported_client' |
33 self._client_id = client_id | 35 self._client_id = client_id |
34 | 36 |
35 | 37 |
36 class MockFindit(Findit): # pylint: disable = W | 38 class MockFindit(Findit): # pylint: disable = W |
37 """Overwrite abstract method of Findit for testing.""" | 39 """Overwrite abstract method of Findit for testing.""" |
38 | 40 |
39 def __init__(self): | 41 def __init__(self): |
40 super(MockFindit, self).__init__(MOCK_REPOSITORY) | 42 super(MockFindit, self).__init__(MOCK_GET_REPOSITORY) |
41 | 43 |
42 @classmethod | 44 @classmethod |
43 def _ClientID(cls): | 45 def _ClientID(cls): |
44 return CrashClient.FRACAS | 46 return CrashClient.FRACAS |
45 | 47 |
46 def ProcessResultForPublishing(self, result, key): | 48 def ProcessResultForPublishing(self, result, key): |
47 return result | 49 return result |
48 | 50 |
49 | 51 |
50 class FinditTest(PredatorTestCase): | 52 class FinditTest(PredatorTestCase): |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 'client_id': self.findit.client_id, | 122 'client_id': self.findit.client_id, |
121 'result': copy.deepcopy(analysis_result), | 123 'result': copy.deepcopy(analysis_result), |
122 } | 124 } |
123 | 125 |
124 analysis = FracasCrashAnalysis.Create(crash_identifiers) | 126 analysis = FracasCrashAnalysis.Create(crash_identifiers) |
125 analysis.result = analysis_result | 127 analysis.result = analysis_result |
126 | 128 |
127 self.assertDictEqual(self.findit.GetPublishableResult(crash_identifiers, | 129 self.assertDictEqual(self.findit.GetPublishableResult(crash_identifiers, |
128 analysis), | 130 analysis), |
129 expected_processed_result) | 131 expected_processed_result) |
OLD | NEW |