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

41 lines
783 B
Python
Raw Normal View History

# -*- coding: utf-8 -*-
from django.contrib.auth.models import AnonymousUser
from bthlabs_jsonrpc_django import auth_checks
def test_is_authenticated_anonymous_user(rf):
# Given
request = rf.get('/')
request.user = AnonymousUser()
# When
result = auth_checks.is_authenticated(request)
# Then
assert result is False
def test_is_authenticated_inactive(rf, inactive_user):
# Given
request = rf.get('/')
request.user = inactive_user
# When
result = auth_checks.is_authenticated(request)
# Then
assert result is False
def test_is_authenticated_ok(rf, user):
# Given
request = rf.get('/')
request.user = user
# When
result = auth_checks.is_authenticated(request)
# Then
assert result is True