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

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 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 side-by-side diff with in-line comments
Download patch
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..9882850636cd9a61f68dae51adb570e0626724d1
--- /dev/null
+++ b/appengine/findit/model/crash/test/crash_config_test.py
@@ -0,0 +1,77 @@
+# 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
+import pickle
+import zlib
+
+from google.appengine.api import users
+
+from common.findit_testcase import FinditTestCase
+from model.crash.crash_config import CrashConfig
+
+
+DUMMY_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_STR_COMPONENT_PATTERNS = {
+ "path_function_component": [
+ [
+ "src/comp1.*",
+ "",
+ "Comp1>Dummy"
+ ],
+ [
+ "src/comp2.*",
+ "func2.*",
+ "Comp2>Dummy"
+ ],
+ ],
+ "top_n": 4
+}
+
+CONFIG_DATA = {
+ 'compressed_component_classifier': zlib.compress(pickle.dumps(
+ DUMMY_COMPONENT_PATTERNS)),
+}
+
+
+class CrashAnalysisTest(FinditTestCase):
+
+ def testGetDecompressedComponentClassifierSetting(self):
+ CrashConfig.Get().Update(
+ users.User(email='admin@chromium.org'), True, **{})
+
+ self.assertEqual(CrashConfig.Get().component_classifier, {})
+
+ CrashConfig.Get().Update(
+ users.User(email='admin@chromium.org'), True, **CONFIG_DATA)
+
+ self.assertEqual(CrashConfig.Get().component_classifier,
+ DUMMY_COMPONENT_PATTERNS)
+
+ def testGetComponentClassifierSettingString(self):
+ CrashConfig.Get().Update(
+ users.User(email='admin@chromium.org'), True, **{})
+
+ self.assertEqual(CrashConfig.Get().str_component_classifier, {})
+
+ CrashConfig.Get().Update(
+ users.User(email='admin@chromium.org'), True, **CONFIG_DATA)
+
+ self.assertEqual(CrashConfig.Get().str_component_classifier,
+ DUMMY_STR_COMPONENT_PATTERNS)

Powered by Google App Engine
This is Rietveld 408576698