Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow null as phone value for participant #298

Merged
merged 1 commit into from
Jul 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion backend/serializers/participant_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ class Meta:
validate=[
validate.Length(max=13),
validate.Regexp("^[+]*[(]{0,1}[0-9]{1,4}[)]{0,1}[-\s\./0-9]*$"),
]
],
allow_none=True,
)
slack = fields.Str(
validate=[validate.Length(max=21), validate.Regexp("^[a-z0-9][a-z0-9._-]*$")]
Expand Down
9 changes: 9 additions & 0 deletions backend/tests/test_participants_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ def test_create_participant_when_logged_in(app, auth_client, new_participant):
assert value in response


def test_create_participant_wiht_none_as_phone(auth_client, new_participant):
new_participant["phone"] = None

rv = auth_client.post("/participants/", json=new_participant)
response = rv.get_json()
assert rv.status_code == HTTPStatus.CREATED
assert response["phone"] is None


def test_try_create_participant_without_payload(auth_client):
"""Test try to create new participant without payload."""
rv = auth_client.post("/participants/", json={})
Expand Down