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

Side by Side Diff: appengine/findit/model/crash/test/crash_config_test.py

Issue 1914113002: [Findit] Enable project classifier and component classifier (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Address comments. Created 4 years, 7 months 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 re
6
7 from google.appengine.api import users
8
9 from common.findit_testcase import FinditTestCase
10 from model.crash.crash_config import CrashConfig
11
12
13 DUMMY_COMPILED_COMPONENT_PATTERNS = {
14 "path_function_component": [
15 [
16 re.compile("src/comp1.*"),
17 None,
18 "Comp1>Dummy"
19 ],
20 [
21 re.compile("src/comp2.*"),
22 re.compile("func2.*"),
23 "Comp2>Dummy"
24 ],
25 ],
26 "top_n": 4
27 }
28
29
30 DUMMY_COMPONENT_PATTERNS = {
31 "path_function_component": [
32 [
33 "src/comp1.*",
34 "",
35 "Comp1>Dummy"
36 ],
37 [
38 "src/comp2.*",
39 "func2.*",
40 "Comp2>Dummy"
41 ],
42 ],
43 "top_n": 4
44 }
45
46 CONFIG_DATA = {
47 'component_classifier': DUMMY_COMPONENT_PATTERNS,
48 }
49
50
51 class CrashAnalysisTest(FinditTestCase):
52
53 def testGetCompiledComponentClassifierSetting(self):
54 crash_config = CrashConfig.Get()
55 crash_config.Update(
56 users.User(email='admin@chromium.org'), True, **CONFIG_DATA)
57
58 self.assertEqual(crash_config.component_classifier,
59 DUMMY_COMPONENT_PATTERNS)
60 self.assertEqual(len(crash_config.compiled_component_classifier),
61 len(DUMMY_COMPILED_COMPONENT_PATTERNS))
62 for i, (path, function, component) in enumerate(
63 crash_config.component_classifier['path_function_component']):
64 path_regx, function_regx, component_2 = (
65 DUMMY_COMPILED_COMPONENT_PATTERNS['path_function_component'][i])
66 self.assertEqual(path, path_regx.pattern)
67 if not function:
68 self.assertIsNone(function_regx)
69 else:
70 self.assertEqual(function, function_regx.pattern)
71 self.assertEqual(component, component_2)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698