This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
2020-07-20 08:57:12 +00:00
|
|
|
"""passbook core task tests"""
|
2020-07-01 20:27:58 +00:00
|
|
|
from django.test import TestCase
|
|
|
|
from django.utils.timezone import now
|
2020-07-01 20:35:38 +00:00
|
|
|
from guardian.shortcuts import get_anonymous_user
|
2020-07-01 20:27:58 +00:00
|
|
|
|
|
|
|
from passbook.core.models import Token
|
2020-07-20 08:57:12 +00:00
|
|
|
from passbook.core.tasks import clean_expired_models
|
2020-07-01 20:27:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
class TestTasks(TestCase):
|
|
|
|
"""Test Tasks"""
|
|
|
|
|
|
|
|
def test_token_cleanup(self):
|
|
|
|
"""Test Token cleanup task"""
|
2020-07-01 20:35:38 +00:00
|
|
|
Token.objects.create(expires=now(), user=get_anonymous_user())
|
|
|
|
self.assertEqual(Token.objects.all().count(), 1)
|
2020-07-20 08:57:12 +00:00
|
|
|
clean_expired_models()
|
2020-07-01 20:35:38 +00:00
|
|
|
self.assertEqual(Token.objects.all().count(), 0)
|