Skip to content

Commit

Permalink
Removed the oneOf validation in the get_notification_response schema.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rebecca Law committed Jan 4, 2017
1 parent c8b11ff commit 7f9111f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
26 changes: 0 additions & 26 deletions app/v2/notifications/notification_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,6 @@
"description": "GET notification response schema",
"type": "object",
"title": "response v2/notification",
"oneOf": [
{"properties": {
"email_address": {"type": "string", "format": "email_address"},
"type": {"enum": ["email"]},

"phone_number": {"type": "null"},
"line_1": {"type": "null"},
"postcode": {"type": "null"}
}},
{"properties": {
"phone_number": {"type": "string", "format": "phone_number"},
"type": {"enum": ["sms"]},

"email_address": {"type": "null"},
"line_1": {"type": "null"},
"postcode": {"type": "null"}
}},
{"properties": {
"line_1": {"type": "string", "minLength": 1},
"postcode": {"type": "string", "minLength": 1},
"type": {"enum": ["letter"]},

"email_address": {"type": "null"},
"phone_number": {"type": "null"}
}}
],
"properties": {
"id": uuid,
"reference": {"type": ["string", "null"]},
Expand Down
26 changes: 26 additions & 0 deletions tests/app/v2/notifications/test_notification_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from app.v2.notifications.notification_schemas import (
get_notifications_request,
get_notification_response,
post_sms_request as post_sms_request_schema,
post_sms_response as post_sms_response_schema,
post_email_request as post_email_request_schema,
Expand Down Expand Up @@ -309,3 +310,28 @@ def test_post_sms_response_schema_invalid_template_uri_raises_validation_error(r
assert error['status_code'] == 400
assert error['errors'] == [{'error': 'ValidationError',
'message': "template invalid-uri is not a uri"}]


def test_get_notifications_response_with_email_and_phone_number():
response = {"id": str(uuid.uuid4()),
"reference": "something",
"email_address": None,
"phone_number": "+447115411111",
"line_1": None,
"line_2": None,
"line_3": None,
"line_4": None,
"line_5": None,
"line_6": None,
"postcode": None,
"type": "email",
"status": "delivered",
"template": {"id": str(uuid.uuid4()), "version": 1, "uri": "http://template/id"},
"body": "some body",
"subject": "some subject",
"created_at": "2016-01-01",
"sent_at": "2016-01-01",
"completed_at": "2016-01-01"
}

assert validate(response, get_notification_response) == response

0 comments on commit 7f9111f

Please sign in to comment.