mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-10 04:50:16 +02:00
48 lines
978 B
Python
48 lines
978 B
Python
"""
|
|
Test sentinel user
|
|
"""
|
|
|
|
# Django
|
|
from django.contrib.auth.models import User
|
|
from django.test import TestCase
|
|
|
|
# Alliance Auth
|
|
from allianceauth.framework.api.user import get_sentinel_user
|
|
|
|
|
|
class TestSentinelUser(TestCase):
|
|
"""
|
|
Tests for the sentinel user
|
|
"""
|
|
|
|
def test_should_create_user_when_it_does_not_exist(self) -> None:
|
|
"""
|
|
Test should create a sentinel user when it doesn't exist
|
|
|
|
:return:
|
|
:rtype:
|
|
"""
|
|
|
|
# when
|
|
user = get_sentinel_user()
|
|
|
|
# then
|
|
self.assertEqual(first=user.username, second="deleted")
|
|
|
|
def test_should_return_user_when_it_does(self) -> None:
|
|
"""
|
|
Test should return sentinel user when it exists
|
|
|
|
:return:
|
|
:rtype:
|
|
"""
|
|
|
|
# given
|
|
User.objects.create_user(username="deleted")
|
|
|
|
# when
|
|
user = get_sentinel_user()
|
|
|
|
# then
|
|
self.assertEqual(first=user.username, second="deleted")
|