Esempio n. 1
0
    def test_log_user_permissions1(self):
        with self.assertLogs(logger="django_tools.permissions",
                             level=logging.DEBUG) as log:
            log_user_permissions(self.normal_user)

        assert log.output == [
            "DEBUG:django_tools.permissions:User 'normal_test_user' has no permission!"
        ]
Esempio n. 2
0
    def test_log_user_permissions1(self):
        with LoggingBuffer(name=None, level=logging.ERROR) as log:
            log_user_permissions(self.normal_user)

        self.assertEqual(
            log.get_messages(),
            "DEBUG:django_tools.permissions:User 'normal_test_user' has no permission!"
        )
Esempio n. 3
0
    def test_log_user_permissions1(self):
        with LoggingBuffer(name="django_tools.permissions",
                           level=logging.DEBUG) as log:
            log_user_permissions(self.normal_user)

        assert_pformat_equal(
            log.get_messages(),
            "DEBUG:django_tools.permissions:User 'normal_test_user' has no permission!"
        )
Esempio n. 4
0
    def test_log_user_permissions2(self):
        with self.assertLogs(logger="django_tools.permissions",
                             level=logging.DEBUG) as log:
            log_user_permissions(self.staff_user)

        assert log.output == [
            "DEBUG:django_tools.permissions:User 'staff_test_user' has permissions:\n"
            '* django_tools_test_app.add_permissiontestmodel\n'
            '* django_tools_test_app.change_permissiontestmodel\n'
            '* django_tools_test_app.delete_permissiontestmodel\n'
            '* django_tools_test_app.extra_permission',
        ]
Esempio n. 5
0
    def test_log_user_permissions2(self):
        with LoggingBuffer(name=None, level=logging.ERROR) as log:
            log_user_permissions(self.staff_user)

        messages = [line.strip() for line in log.get_messages().splitlines()]
        pprint.pprint(messages)

        self.assertEqual(
            messages,
            [
                "DEBUG:django_tools.permissions:User 'staff_test_user' has permissions:",
                "* django_tools_test_app.add_permissiontestmodel",
                "* django_tools_test_app.change_permissiontestmodel",
                "* django_tools_test_app.delete_permissiontestmodel",
                "* django_tools_test_app.extra_permission"
            ]
        )