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

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: Rebase 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 setUp(self):
54 super(CrashAnalysisTest, self).setUp()
55 CrashConfig.Get().Update(
56 users.User(email='admin@chromium.org'), True, **CONFIG_DATA)
57
58 def _VerifyTwoCompiledComponentClassifierEqual(self, setting1, setting2):
59 self.assertEqual(setting1['top_n'], setting2['top_n'])
60 self.assertEqual(len(setting1['path_function_component']),
61 len(setting2['path_function_component']))
62
63 for i, (path1, function1, component1) in enumerate(
64 setting1['path_function_component']):
65 path2, function2, component2 = setting2['path_function_component'][i]
66 self.assertEqual(path1.pattern, path2.pattern)
67 if not function1:
68 self.assertEqual(function1, function2)
69 else:
70 self.assertEqual(function1.pattern, function2.pattern)
71 self.assertEqual(component1, component2)
72
73 def testClearCache(self):
74 crash_config = CrashConfig.Get()
75 crash_config.ClearCache()
76
77 self.assertIsNone(crash_config.cached_component_classifier)
78 self._VerifyTwoCompiledComponentClassifierEqual(
79 crash_config.compiled_component_classifier,
80 DUMMY_COMPILED_COMPONENT_PATTERNS)
81
82 def testGetCompiledComponentClassifierSettingFromCache(self):
83 crash_config = CrashConfig.Get()
84 crash_config.ClearCache()
85
86 crash_config.cached_component_classifier = DUMMY_COMPILED_COMPONENT_PATTERNS
87 self._VerifyTwoCompiledComponentClassifierEqual(
88 crash_config.compiled_component_classifier,
89 DUMMY_COMPILED_COMPONENT_PATTERNS)
90
91 def testGetCompiledComponentClassifierSetting(self):
92 crash_config = CrashConfig.Get()
93 self.assertEqual(crash_config.component_classifier,
94 DUMMY_COMPONENT_PATTERNS)
95 self._VerifyTwoCompiledComponentClassifierEqual(
96 crash_config.compiled_component_classifier,
97 DUMMY_COMPILED_COMPONENT_PATTERNS)
98
OLDNEW
« no previous file with comments | « appengine/findit/model/crash/crash_config.py ('k') | appengine/findit/templates/crash/crash_config.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698