authentik/passbook/core/tests/tests_tasks.py

19 lines
568 B
Python
Raw Normal View History

2020-07-01 21:27:58 +01:00
"""passbook user view tests"""
from django.test import TestCase
from django.utils.timezone import now
2020-07-01 21:35:38 +01:00
from guardian.shortcuts import get_anonymous_user
2020-07-01 21:27:58 +01:00
from passbook.core.models import Token
2020-07-01 21:35:38 +01:00
from passbook.core.tasks import clean_tokens
2020-07-01 21:27:58 +01:00
class TestTasks(TestCase):
"""Test Tasks"""
def test_token_cleanup(self):
"""Test Token cleanup task"""
2020-07-01 21:35:38 +01:00
Token.objects.create(expires=now(), user=get_anonymous_user())
self.assertEqual(Token.objects.all().count(), 1)
2020-07-01 21:27:58 +01:00
clean_tokens()
2020-07-01 21:35:38 +01:00
self.assertEqual(Token.objects.all().count(), 0)