-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4dc3a5f
commit dc98940
Showing
2 changed files
with
38 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,8 +4,9 @@ | |
import pytest | ||
from django.db import IntegrityError | ||
|
||
from lacommunaute.users.enums import EmailLastSeenKind | ||
from lacommunaute.users.factories import EmailLastSeenFactory | ||
from lacommunaute.users.models import User | ||
from lacommunaute.users.models import EmailLastSeen, User | ||
|
||
|
||
email = "[email protected]" | ||
|
@@ -51,3 +52,29 @@ def test_soft_delete(db, email_last_seen): | |
assert email_last_seen.deleted_at is not None | ||
assert email_last_seen.email is None | ||
assert email_last_seen.email_hash not in [None, ""] | ||
|
||
|
||
# EmailLastSeenQuerySet tests | ||
|
||
|
||
@pytest.mark.parametrize("kind", [kind for kind, _ in EmailLastSeenKind.choices]) | ||
def test_seen(db, email_last_seen, kind): | ||
EmailLastSeen.objects.seen(email, kind) | ||
|
||
email_last_seen.refresh_from_db() | ||
assert email_last_seen.last_seen_kind == kind | ||
assert email_last_seen.last_seen_at is not None | ||
|
||
|
||
def test_seen_invalid_kind(db, email_last_seen): | ||
with pytest.raises(ValueError): | ||
EmailLastSeen.objects.seen(email, "invalid_kind") | ||
|
||
|
||
@pytest.mark.parametrize("kind", [kind for kind, _ in EmailLastSeenKind.choices]) | ||
def test_seen_unknown_email(db, kind): | ||
EmailLastSeen.objects.seen(email, kind) | ||
|
||
email_last_seen = EmailLastSeen.objects.get(email=email) | ||
assert email_last_seen.last_seen_kind == kind | ||
assert email_last_seen.last_seen_at is not None |