mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-18 05:28:49 -04:00
remove letters from v2/notifications
This commit is contained in:
@@ -36,20 +36,6 @@ def create_post_email_response_from_notification(
|
|||||||
return resp
|
return resp
|
||||||
|
|
||||||
|
|
||||||
def create_post_letter_response_from_notification(
|
|
||||||
notification_id, client_reference, template_id, template_version, service_id,
|
|
||||||
content, subject, url_root
|
|
||||||
):
|
|
||||||
resp = __create_notification_response(
|
|
||||||
notification_id, client_reference, template_id, template_version, service_id, url_root
|
|
||||||
)
|
|
||||||
resp['content'] = {
|
|
||||||
"body": content,
|
|
||||||
"subject": subject
|
|
||||||
}
|
|
||||||
return resp
|
|
||||||
|
|
||||||
|
|
||||||
def __create_notification_response(
|
def __create_notification_response(
|
||||||
notification_id, client_reference, template_id, template_version, service_id, url_root
|
notification_id, client_reference, template_id, template_version, service_id, url_root
|
||||||
):
|
):
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
from app.models import (
|
from app.models import (
|
||||||
NOTIFICATION_STATUS_LETTER_ACCEPTED,
|
|
||||||
NOTIFICATION_STATUS_LETTER_RECEIVED,
|
|
||||||
NOTIFICATION_STATUS_TYPES,
|
NOTIFICATION_STATUS_TYPES,
|
||||||
NOTIFICATION_TYPES,
|
NOTIFICATION_TYPES,
|
||||||
)
|
)
|
||||||
@@ -48,7 +46,7 @@ get_notification_response = {
|
|||||||
"line_5": {"type": ["string", "null"]},
|
"line_5": {"type": ["string", "null"]},
|
||||||
"line_6": {"type": ["string", "null"]},
|
"line_6": {"type": ["string", "null"]},
|
||||||
"postcode": {"type": ["string", "null"]},
|
"postcode": {"type": ["string", "null"]},
|
||||||
"type": {"enum": ["sms", "letter", "email"]},
|
"type": {"enum": ["sms", "email"]},
|
||||||
"status": {"type": "string"},
|
"status": {"type": "string"},
|
||||||
"template": template,
|
"template": template,
|
||||||
"body": {"type": "string"},
|
"body": {"type": "string"},
|
||||||
@@ -75,8 +73,7 @@ get_notifications_request = {
|
|||||||
"status": {
|
"status": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
"enum": NOTIFICATION_STATUS_TYPES +
|
"enum": NOTIFICATION_STATUS_TYPES
|
||||||
[NOTIFICATION_STATUS_LETTER_ACCEPTED + ', ' + NOTIFICATION_STATUS_LETTER_RECEIVED]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"template_type": {
|
"template_type": {
|
||||||
@@ -216,46 +213,3 @@ post_email_response = {
|
|||||||
},
|
},
|
||||||
"required": ["id", "content", "uri", "template"]
|
"required": ["id", "content", "uri", "template"]
|
||||||
}
|
}
|
||||||
|
|
||||||
post_letter_request = {
|
|
||||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
||||||
"description": "POST letter notification schema",
|
|
||||||
"type": "object",
|
|
||||||
"title": "POST v2/notifications/letter",
|
|
||||||
"properties": {
|
|
||||||
"reference": {"type": "string"},
|
|
||||||
"template_id": uuid,
|
|
||||||
"personalisation": personalisation
|
|
||||||
},
|
|
||||||
"required": ["template_id", "personalisation"],
|
|
||||||
"additionalProperties": False
|
|
||||||
}
|
|
||||||
|
|
||||||
letter_content = {
|
|
||||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
||||||
"description": "Letter content for POST letter notification",
|
|
||||||
"type": "object",
|
|
||||||
"title": "notification letter content",
|
|
||||||
"properties": {
|
|
||||||
"body": {"type": "string"},
|
|
||||||
"subject": {"type": "string"}
|
|
||||||
},
|
|
||||||
"required": ["body", "subject"]
|
|
||||||
}
|
|
||||||
|
|
||||||
post_letter_response = {
|
|
||||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
||||||
"description": "POST sms notification response schema",
|
|
||||||
"type": "object",
|
|
||||||
"title": "response v2/notifications/letter",
|
|
||||||
"properties": {
|
|
||||||
"id": uuid,
|
|
||||||
"reference": {"type": ["string", "null"]},
|
|
||||||
"content": letter_content,
|
|
||||||
"uri": {"type": "string", "format": "uri"},
|
|
||||||
"template": template,
|
|
||||||
# letters cannot be scheduled
|
|
||||||
"scheduled_for": {"type": "null"}
|
|
||||||
},
|
|
||||||
"required": ["id", "content", "uri", "template"]
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -382,7 +382,7 @@ def test_get_all_notifications_filter_by_status_invalid_status(client, sample_no
|
|||||||
assert len(json_response['errors']) == 1
|
assert len(json_response['errors']) == 1
|
||||||
assert json_response['errors'][0]['message'] == "status elephant is not one of [cancelled, created, sending, " \
|
assert json_response['errors'][0]['message'] == "status elephant is not one of [cancelled, created, sending, " \
|
||||||
"sent, delivered, pending, failed, technical-failure, temporary-failure, permanent-failure, " \
|
"sent, delivered, pending, failed, technical-failure, temporary-failure, permanent-failure, " \
|
||||||
"pending-virus-check, validation-failed, virus-scan-failed, returned-letter, accepted, received]"
|
"pending-virus-check, validation-failed, virus-scan-failed, returned-letter]"
|
||||||
|
|
||||||
|
|
||||||
def test_get_all_notifications_filter_by_multiple_statuses(client, sample_template):
|
def test_get_all_notifications_filter_by_multiple_statuses(client, sample_template):
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ def test_get_notifications_request_invalid_statuses(
|
|||||||
partial_error_status = "is not one of " \
|
partial_error_status = "is not one of " \
|
||||||
"[cancelled, created, sending, sent, delivered, pending, failed, " \
|
"[cancelled, created, sending, sent, delivered, pending, failed, " \
|
||||||
"technical-failure, temporary-failure, permanent-failure, pending-virus-check, " \
|
"technical-failure, temporary-failure, permanent-failure, pending-virus-check, " \
|
||||||
"validation-failed, virus-scan-failed, returned-letter, accepted, received]"
|
"validation-failed, virus-scan-failed, returned-letter]"
|
||||||
|
|
||||||
with pytest.raises(ValidationError) as e:
|
with pytest.raises(ValidationError) as e:
|
||||||
validate({'status': invalid_statuses + valid_statuses}, get_notifications_request)
|
validate({'status': invalid_statuses + valid_statuses}, get_notifications_request)
|
||||||
@@ -93,7 +93,7 @@ def test_get_notifications_request_invalid_statuses_and_template_types():
|
|||||||
for invalid_status in ["elephant", "giraffe"]:
|
for invalid_status in ["elephant", "giraffe"]:
|
||||||
assert "status {} is not one of [cancelled, created, sending, sent, delivered, " \
|
assert "status {} is not one of [cancelled, created, sending, sent, delivered, " \
|
||||||
"pending, failed, technical-failure, temporary-failure, permanent-failure, " \
|
"pending, failed, technical-failure, temporary-failure, permanent-failure, " \
|
||||||
"pending-virus-check, validation-failed, virus-scan-failed, returned-letter, accepted, received]".format(
|
"pending-virus-check, validation-failed, virus-scan-failed, returned-letter]".format(
|
||||||
invalid_status
|
invalid_status
|
||||||
) in error_messages
|
) in error_messages
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user