| 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..878e996e6d33b4f128440fab6c4f097032be5976
|
| --- /dev/null
|
| +++ b/appengine/findit/model/crash/test/crash_config_test.py
|
| @@ -0,0 +1,71 @@
|
| +# 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 testGetCompiledComponentClassifierSetting(self):
|
| + crash_config = CrashConfig.Get()
|
| + crash_config.Update(
|
| + users.User(email='admin@chromium.org'), True, **CONFIG_DATA)
|
| +
|
| + self.assertEqual(crash_config.component_classifier,
|
| + DUMMY_COMPONENT_PATTERNS)
|
| + self.assertEqual(len(crash_config.compiled_component_classifier),
|
| + len(DUMMY_COMPILED_COMPONENT_PATTERNS))
|
| + for i, (path, function, component) in enumerate(
|
| + crash_config.component_classifier['path_function_component']):
|
| + path_regx, function_regx, component_2 = (
|
| + DUMMY_COMPILED_COMPONENT_PATTERNS['path_function_component'][i])
|
| + self.assertEqual(path, path_regx.pattern)
|
| + if not function:
|
| + self.assertIsNone(function_regx)
|
| + else:
|
| + self.assertEqual(function, function_regx.pattern)
|
| + self.assertEqual(component, component_2)
|
|
|