1
0
bthlabs-jsonrpc/packages/bthlabs-jsonrpc-django/tests/auth_checks/test_is_staff.py

31 lines
615 B
Python
Raw Normal View History

# -*- coding: utf-8 -*-
2024-01-15 20:20:10 +00:00
# type: ignore
from django.contrib.auth.models import User
from django.test import RequestFactory
from bthlabs_jsonrpc_django import auth_checks
2024-01-15 20:20:10 +00:00
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
2024-01-15 20:20:10 +00:00
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