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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/findit/model/crash/test/crash_config_test.py
diff --git a/appengine/findit/model/crash/test/crash_config_test.py b/appengine/findit/model/crash/test/crash_config_test.py
new file mode 100644
index 0000000000000000000000000000000000000000..2be2b75c2bbd21083ce67af64fb3e2fdb7d4039c
--- /dev/null
+++ b/appengine/findit/model/crash/test/crash_config_test.py
@@ -0,0 +1,98 @@
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import re
+
+from google.appengine.api import users
+
+from common.findit_testcase import FinditTestCase
+from model.crash.crash_config import CrashConfig
+
+
+DUMMY_COMPILED_COMPONENT_PATTERNS = {
+ "path_function_component": [
+ [
+ re.compile("src/comp1.*"),
+ None,
+ "Comp1>Dummy"
+ ],
+ [
+ re.compile("src/comp2.*"),
+ re.compile("func2.*"),
+ "Comp2>Dummy"
+ ],
+ ],
+ "top_n": 4
+}
+
+
+DUMMY_COMPONENT_PATTERNS = {
+ "path_function_component": [
+ [
+ "src/comp1.*",
+ "",
+ "Comp1>Dummy"
+ ],
+ [
+ "src/comp2.*",
+ "func2.*",
+ "Comp2>Dummy"
+ ],
+ ],
+ "top_n": 4
+}
+
+CONFIG_DATA = {
+ 'component_classifier': DUMMY_COMPONENT_PATTERNS,
+}
+
+
+class CrashAnalysisTest(FinditTestCase):
+
+ def setUp(self):
+ super(CrashAnalysisTest, self).setUp()
+ CrashConfig.Get().Update(
+ users.User(email='admin@chromium.org'), True, **CONFIG_DATA)
+
+ def _VerifyTwoCompiledComponentClassifierEqual(self, setting1, setting2):
+ self.assertEqual(setting1['top_n'], setting2['top_n'])
+ self.assertEqual(len(setting1['path_function_component']),
+ len(setting2['path_function_component']))
+
+ for i, (path1, function1, component1) in enumerate(
+ setting1['path_function_component']):
+ path2, function2, component2 = setting2['path_function_component'][i]
+ self.assertEqual(path1.pattern, path2.pattern)
+ if not function1:
+ self.assertEqual(function1, function2)
+ else:
+ self.assertEqual(function1.pattern, function2.pattern)
+ self.assertEqual(component1, component2)
+
+ def testClearCache(self):
+ crash_config = CrashConfig.Get()
+ crash_config.ClearCache()
+
+ self.assertIsNone(crash_config.cached_component_classifier)
+ self._VerifyTwoCompiledComponentClassifierEqual(
+ crash_config.compiled_component_classifier,
+ DUMMY_COMPILED_COMPONENT_PATTERNS)
+
+ def testGetCompiledComponentClassifierSettingFromCache(self):
+ crash_config = CrashConfig.Get()
+ crash_config.ClearCache()
+
+ crash_config.cached_component_classifier = DUMMY_COMPILED_COMPONENT_PATTERNS
+ self._VerifyTwoCompiledComponentClassifierEqual(
+ crash_config.compiled_component_classifier,
+ DUMMY_COMPILED_COMPONENT_PATTERNS)
+
+ def testGetCompiledComponentClassifierSetting(self):
+ crash_config = CrashConfig.Get()
+ self.assertEqual(crash_config.component_classifier,
+ DUMMY_COMPONENT_PATTERNS)
+ self._VerifyTwoCompiledComponentClassifierEqual(
+ crash_config.compiled_component_classifier,
+ DUMMY_COMPILED_COMPONENT_PATTERNS)
+
« 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