Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Castellum
castellum
Commits
f2d0337b
Commit
f2d0337b
authored
May 04, 2018
by
Stefan Bunde
Browse files
add test for management command
parent
08b37046
Pipeline
#181
passed with stage
in 15 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
castellum_core/tests/castellum_auth/management_commands/test_deactivate_expired_user_accounts.py
0 → 100644
View file @
f2d0337b
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
()
castellum_core/tox.ini
View file @
f2d0337b
...
...
@@ -28,6 +28,7 @@ max-line-length=100
deps
=
pytest-django
pytest-cov
model_mommy
setenv
=
PYTHONPATH
=
{toxinidir}/castellum_core:{env:PYTHONPATH:}
commands
=
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment