Commit f2d0337b authored by Stefan Bunde's avatar Stefan Bunde
Browse files

add test for management command

parent 08b37046
Pipeline #181 passed with stage
in 15 seconds
from datetime import date, timedelta
from itertools import cycle
import pytest
from model_mommy import mommy
from castellum_auth.models import User
from castellum_auth.management.commands.deactivate_expired_user_accounts import Command
TODAY = date.today()
FUTURE_DATE = TODAY - timedelta(days=-1)
PAST_DATE = TODAY - timedelta(days=1)
@pytest.mark.django_db
@pytest.mark.parametrize("inactive_user_count, expiration_dates", [
(0, [TODAY]),
(0, [TODAY, FUTURE_DATE]),
(2, [TODAY, FUTURE_DATE, PAST_DATE]),
])
def test_command(inactive_user_count, expiration_dates):
mommy.make(User, expiration_date=cycle(expiration_dates), _quantity=6)
Command().handle()
assert inactive_user_count == User.objects.filter(is_active=False).count()
......@@ -28,6 +28,7 @@ max-line-length=100
deps =
pytest-django
pytest-cov
model_mommy
setenv =
PYTHONPATH = {toxinidir}/castellum_core:{env:PYTHONPATH:}
commands =
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment