| OLD | NEW |
| (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 from crash.stacktrace import StackFrame | |
| 6 from crash.suspect import Suspect | |
| 7 from crash.scorers import aggregators | |
| 8 from crash.scorers.min_distance import MinDistance | |
| 9 from crash.scorers.test.scorer_test_suite import ScorerTestSuite | |
| 10 from crash.scorers.top_frame_index import TopFrameIndex | |
| 11 | |
| 12 | |
| 13 class AggregatorsTest(ScorerTestSuite): | |
| 14 | |
| 15 def testMultiplier(self): | |
| 16 aggregator = aggregators.Multiplier() | |
| 17 self.assertEqual(aggregator.Aggregate([1, 0.5, 0.2]), 0.1) | |
| 18 self.assertEqual(aggregator([None, None]), None) | |
| 19 self.assertEqual(aggregator([1, 0.5, 0.2]), 0.1) | |
| 20 | |
| 21 def testIdentityAggregator(self): | |
| 22 aggregator = aggregators.IdentityAggregator() | |
| 23 self.assertEqual(aggregator.Aggregate([1, 0.5, 0.2]), [1, 0.5, 0.2]) | |
| 24 self.assertEqual(aggregator([1, 0.5, 0.2]), [1, 0.5, 0.2]) | |
| 25 | |
| 26 def testChangedFilesAggregator(self): | |
| 27 aggregator = aggregators.ChangedFilesAggregator() | |
| 28 file_info_list = [ | |
| 29 [ | |
| 30 {'file': 'f1.cc', 'blame_url': 'https://repo_url', | |
| 31 'info': 'scorer 1'}, | |
| 32 {'file': 'f2.cc', 'blame_url': 'https://repo_url', | |
| 33 'info': 'scorer 1'}, | |
| 34 ], | |
| 35 [ | |
| 36 {'file': 'f1.cc', 'blame_url': 'https://repo_url', | |
| 37 'info': None}, | |
| 38 {'file': 'f2.cc', 'blame_url': 'https://repo_url', | |
| 39 'info': 'scorer 2'}, | |
| 40 ], | |
| 41 ] | |
| 42 self.assertEqual(aggregator(file_info_list), | |
| 43 [{'file': 'f1.cc', 'blame_url': 'https://repo_url', | |
| 44 'info': 'scorer 1'}, | |
| 45 {'file': 'f2.cc', 'blame_url': 'https://repo_url', | |
| 46 'info': 'scorer 1\nscorer 2'}]) | |
| 47 | |
| 48 | |
| OLD | NEW |