diff options
| author | averybigant <averybigant@gmail.com> | 2014-11-05 14:01:49 +0800 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2014-11-11 16:29:32 +0100 |
| commit | b7a5b6ab8672daf907ba57e50edbed4cad596d4b (patch) | |
| tree | abd0bf721e3ea3df856aa8a358c96d69787177b4 /tests | |
| parent | b3fd39f7c8921b314f12dd53ee65740464d4a5f1 (diff) | |
Fixed #23750 -- Allowed core.checks.register to be used as a function
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/check_framework/tests.py | 42 |
1 files changed, 36 insertions, 6 deletions
diff --git a/tests/check_framework/tests.py b/tests/check_framework/tests.py index 4d29429313..43b579d383 100644 --- a/tests/check_framework/tests.py +++ b/tests/check_framework/tests.py @@ -31,17 +31,47 @@ class DummyObj(object): class SystemCheckFrameworkTests(TestCase): def test_register_and_run_checks(self): - calls = [0] - - registry = CheckRegistry() - @registry.register() def f(**kwargs): calls[0] += 1 return [1, 2, 3] + + def f2(**kwargs): + return [4, ] + + def f3(**kwargs): + return [5, ] + + calls = [0] + + # test register as decorator + registry = CheckRegistry() + registry.register()(f) + registry.register("tag1", "tag2")(f2) + registry.register("tag2", deploy=True)(f3) + + # test register as function + registry2 = CheckRegistry() + registry2.register(f) + registry2.register(f2, "tag1", "tag2") + registry2.register(f3, "tag2", deploy=True) + + # check results errors = registry.run_checks() - self.assertEqual(errors, [1, 2, 3]) - self.assertEqual(calls[0], 1) + errors2 = registry2.run_checks() + self.assertEqual(errors, errors2) + self.assertEqual(sorted(errors), [1, 2, 3, 4]) + self.assertEqual(calls[0], 2) + + errors = registry.run_checks(tags=["tag1"]) + errors2 = registry2.run_checks(tags=["tag1"]) + self.assertEqual(errors, errors2) + self.assertEqual(sorted(errors), [4]) + + errors = registry.run_checks(tags=["tag1", "tag2"], include_deployment_checks=True) + errors2 = registry2.run_checks(tags=["tag1", "tag2"], include_deployment_checks=True) + self.assertEqual(errors, errors2) + self.assertEqual(sorted(errors), [4, 5]) class MessageTests(TestCase): |
