31 lines
615 B
Python
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
|