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

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 and 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 import pickle
7 import zlib
8
9 from google.appengine.api import users
10
11 from common.findit_testcase import FinditTestCase
12 from model.crash.crash_config import CrashConfig
13
14
15 DUMMY_COMPONENT_PATTERNS = {
16 "path_function_component": [
17 [
18 re.compile("src/comp1.*"),
19 None,
20 "Comp1>Dummy"
21 ],
22 [
23 re.compile("src/comp2.*"),
24 re.compile("func2.*"),
25 "Comp2>Dummy"
26 ],
27 ],
28 "top_n": 4
29 }
30
31 DUMMY_STR_COMPONENT_PATTERNS = {
32 "path_function_component": [
33 [
34 "src/comp1.*",
35 "",
36 "Comp1>Dummy"
37 ],
38 [
39 "src/comp2.*",
40 "func2.*",
41 "Comp2>Dummy"
42 ],
43 ],
44 "top_n": 4
45 }
46
47 CONFIG_DATA = {
48 'compressed_component_classifier': zlib.compress(pickle.dumps(
49 DUMMY_COMPONENT_PATTERNS)),
50 }
51
52
53 class CrashAnalysisTest(FinditTestCase):
54
55 def testGetDecompressedComponentClassifierSetting(self):
56 CrashConfig.Get().Update(
57 users.User(email='admin@chromium.org'), True, **{})
58
59 self.assertEqual(CrashConfig.Get().component_classifier, {})
60
61 CrashConfig.Get().Update(
62 users.User(email='admin@chromium.org'), True, **CONFIG_DATA)
63
64 self.assertEqual(CrashConfig.Get().component_classifier,
65 DUMMY_COMPONENT_PATTERNS)
66
67 def testGetComponentClassifierSettingString(self):
68 CrashConfig.Get().Update(
69 users.User(email='admin@chromium.org'), True, **{})
70
71 self.assertEqual(CrashConfig.Get().str_component_classifier, {})
72
73 CrashConfig.Get().Update(
74 users.User(email='admin@chromium.org'), True, **CONFIG_DATA)
75
76 self.assertEqual(CrashConfig.Get().str_component_classifier,
77 DUMMY_STR_COMPONENT_PATTERNS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698