Esempio n. 1
0
    def test_log_group_permissions1(self):
        with self.assertLogs(logger="django_tools.permissions",
                             level=logging.DEBUG) as log:
            log_group_permissions(self.normal_group)

        assert log.output == [
            "DEBUG:django_tools.permissions:User group 'Normal User Group' has no permission!"
        ]
Esempio n. 2
0
    def test_log_group_permissions1(self):
        with LoggingBuffer(name=None, level=logging.ERROR) as log:
            log_group_permissions(self.normal_group)

        self.assertEqual(
            log.get_messages(),
            "DEBUG:django_tools.permissions:User group 'Normal User Group' has no permission!"
        )
Esempio n. 3
0
    def test_log_group_permissions1(self):
        with LoggingBuffer(name="django_tools.permissions",
                           level=logging.DEBUG) as log:
            log_group_permissions(self.normal_group)

        assert_pformat_equal(
            log.get_messages(),
            "DEBUG:django_tools.permissions:User group 'Normal User Group' has no permission!"
        )
Esempio n. 4
0
    def test_log_group_permissions2(self):
        with self.assertLogs(logger="django_tools.permissions",
                             level=logging.DEBUG) as log:
            log_group_permissions(self.staff_group)

        assert log.output == [
            "DEBUG:django_tools.permissions:User group 'Staff User Group' 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_group_permissions2(self):
        with LoggingBuffer(name=None, level=logging.ERROR) as log:
            log_group_permissions(self.staff_group)

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

        self.assertEqual(
            messages,
            [
                "DEBUG:django_tools.permissions:User group 'Staff User Group' 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"
            ]
        )