def test_superuser_check(self): self.assertEqual( check_permission(self.normal_user, "foo.bar", raise_exception=False), False) self.assertEqual(has_perm(self.normal_user, "foo.bar"), False) self.assertEqual( check_permission(self.superuser, "foo.bar", raise_exception=False), True) self.assertEqual(has_perm(self.superuser, "foo.bar"), True)
def test_has_perm_log(self): with LoggingBuffer(name=None, level=logging.ERROR) as log: self.assertEqual(has_perm(self.normal_user, "foo.bar1"), False) self.assertEqual( log.get_messages(), "DEBUG:django_tools.permissions:" "User normal test user has not foo.bar1")
def test_has_perm_log(self): with LoggingBuffer(name="django_tools.permissions", level=logging.DEBUG) as log: assert_pformat_equal(has_perm(self.normal_user, "foo.bar1"), False) assert_pformat_equal( log.get_messages(), "DEBUG:django_tools.permissions:" "User normal_test_user has not foo.bar1")
def test_has_perm_log(self): with self.assertLogs(logger="django_tools.permissions", level=logging.DEBUG) as log: assert_pformat_equal(has_perm(self.normal_user, "foo.bar1"), False) assert log.output == [ "DEBUG:django_tools.permissions:" "User normal_test_user has not foo.bar1" ]
def test_has_perm(self): self.assertTrue( has_perm(self.staff_user, "django_tools_test_app.change_permissiontestmodel"))