예제 #1
0
파일: tests.py 프로젝트: saschpe/django
    def test_register_and_run_checks(self):
        calls = [0]

        registry = CheckRegistry()

        @registry.register()
        def f(**kwargs):
            calls[0] += 1
            return [1, 2, 3]
        errors = registry.run_checks()
        self.assertEqual(errors, [1, 2, 3])
        self.assertEqual(calls[0], 1)
예제 #2
0
파일: tests.py 프로젝트: 6ft/django
    def test_register_and_run_checks(self):
        calls = [0]

        registry = CheckRegistry()

        @registry.register()
        def f(**kwargs):
            calls[0] += 1
            return [1, 2, 3]
        errors = registry.run_checks()
        self.assertEqual(errors, [1, 2, 3])
        self.assertEqual(calls[0], 1)
예제 #3
0
파일: tests.py 프로젝트: suhailvs/django
    def test_register_run_checks_non_iterable(self):
        registry = CheckRegistry()

        @registry.register
        def return_non_iterable(**kwargs):
            return Error('Message')

        msg = (
            'The function %r did not return a list. All functions registered '
            'with the checks registry must return a list.' %
            return_non_iterable)
        with self.assertRaisesMessage(TypeError, msg):
            registry.run_checks()
예제 #4
0
    def test_database_checks_not_run_by_default(self):
        """
        `database` checks are only run when their tag is specified.
        """
        def f1(**kwargs):
            return [5]

        registry = CheckRegistry()
        registry.register(Tags.database)(f1)
        errors = registry.run_checks()
        self.assertEqual(errors, [])

        errors2 = registry.run_checks(tags=[Tags.database])
        self.assertEqual(errors2, [5])
예제 #5
0
파일: tests.py 프로젝트: sreepathidas/ever
 def test_register_no_kwargs_error(self):
     registry = CheckRegistry()
     msg = 'Check functions must accept keyword arguments (**kwargs).'
     with self.assertRaisesMessage(TypeError, msg):
         @registry.register
         def no_kwargs(app_configs, databases):
             pass
예제 #6
0
    def test_database_checks_not_run_by_default(self):
        """
        `database` checks are only run when their tag is specified.
        """
        def f1(**kwargs):
            return [5]

        registry = CheckRegistry()
        registry.register(Tags.database)(f1)
        errors = registry.run_checks()
        self.assertEqual(errors, [])

        errors2 = registry.run_checks(tags=[Tags.database])
        self.assertEqual(errors2, [5])
예제 #7
0
파일: tests.py 프로젝트: ATNC/django
    def test_register_and_run_checks(self):

        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()
        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])
예제 #8
0
파일: tests.py 프로젝트: yephper/django
    def test_register_and_run_checks(self):
        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()
        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])