-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't validate mandatory fields and date_of_birth in PATCH signup req…
…uest if value is missing from the payload
- Loading branch information
1 parent
6b76c82
commit aea117e
Showing
3 changed files
with
60 additions
and
39 deletions.
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import pytest | ||
from freezegun import freeze_time | ||
from rest_framework import status | ||
|
||
from events.tests.utils import versioned_reverse as reverse | ||
from registrations.models import MandatoryFields, SignUp | ||
|
||
# === util methods === | ||
|
||
|
||
def patch_signup(api_client, signup_pk, signup_data): | ||
signup_url = reverse( | ||
"signup-detail", | ||
kwargs={"pk": signup_pk}, | ||
) | ||
|
||
response = api_client.patch(signup_url, signup_data, format="json") | ||
return response | ||
|
||
|
||
def assert_patch_signup(api_client, signup_pk, signup_data): | ||
response = patch_signup(api_client, signup_pk, signup_data) | ||
|
||
assert response.status_code == status.HTTP_200_OK | ||
assert response.data["id"] == signup_pk | ||
|
||
return response | ||
|
||
|
||
@freeze_time("2023-03-14 03:30:00+02:00") | ||
@pytest.mark.django_db | ||
def test__patch_presence_status_of_signup(api_client, registration, signup, user): | ||
registration.audience_min_age = 10 | ||
registration.mandatory_fields = [ | ||
MandatoryFields.PHONE_NUMBER, | ||
MandatoryFields.STREET_ADDRESS, | ||
] | ||
registration.save() | ||
signup.date_of_birth = "2011-01-01" | ||
signup.phone_number = "0441234567" | ||
signup.street_address = "Street address" | ||
signup.save() | ||
api_client.force_authenticate(user) | ||
|
||
signup_data = { | ||
"presence_status": SignUp.PresenceStatus.PRESENT, | ||
} | ||
|
||
response = assert_patch_signup(api_client, signup.id, signup_data) | ||
assert response.data["presence_status"] == SignUp.PresenceStatus.PRESENT |
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