-
Notifications
You must be signed in to change notification settings - Fork 530
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
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import pytest | ||
|
||
from pontoon.base.models import User | ||
|
||
|
||
@pytest.mark.django_db | ||
def test_dismiss_email_consent(member): | ||
"""Test if dismiss_email_consent view works and fails as expected.""" | ||
params = {} | ||
response = member.client.post(f"/dismiss-email-consent/", params) | ||
assert response.status_code == 400 | ||
assert response.json()["message"] == "Bad Request: Value not set" | ||
|
||
params = { | ||
"value": "false", | ||
} | ||
response = member.client.post(f"/dismiss-email-consent/", params) | ||
profile = User.objects.get(pk=member.user.pk).profile | ||
assert profile.email_communications_enabled is False | ||
assert profile.email_consent_dismissed_at is not None | ||
assert response.status_code == 200 | ||
assert response.json()["next"] == "/" | ||
|
||
params = { | ||
"value": "true", | ||
} | ||
response = member.client.post(f"/dismiss-email-consent/", params) | ||
profile = User.objects.get(pk=member.user.pk).profile | ||
assert profile.email_communications_enabled is True | ||
assert profile.email_consent_dismissed_at is not None | ||
assert response.status_code == 200 | ||
assert response.json()["next"] == "/" |