1
0
bthlabs-jsonrpc/packages/bthlabs-jsonrpc-django/tests/auth_checks/test_is_staff.py
2024-01-15 20:20:10 +00:00

31 lines
615 B
Python

# -*- coding: utf-8 -*-
# type: ignore
from django.contrib.auth.models import User
from django.test import RequestFactory
from bthlabs_jsonrpc_django import auth_checks
def test_is_staff_regular_user(rf: RequestFactory, user: User):
# Given
request = rf.get('/')
request.user = user
# When
result = auth_checks.is_staff(request)
# Then
assert result is False
def test_is_staff_ok(rf: RequestFactory, staff_user: User):
# Given
request = rf.get('/')
request.user = staff_user
# When
result = auth_checks.is_staff(request)
# Then
assert result is True