mirror of
https://github.com/GSA/notifications-api.git
synced 2026-09-11 18:38:14 -04:00
@@ -9,7 +9,7 @@ post_create_email_branding_schema = {
|
|||||||
"name": {"type": "string"},
|
"name": {"type": "string"},
|
||||||
"text": {"type": ["string", "null"]},
|
"text": {"type": ["string", "null"]},
|
||||||
"logo": {"type": ["string", "null"]},
|
"logo": {"type": ["string", "null"]},
|
||||||
"brand_type": {"enum": [e.value for e in BrandType]},
|
"brand_type": {"enum": list(BrandType)},
|
||||||
},
|
},
|
||||||
"required": ["name"],
|
"required": ["name"],
|
||||||
}
|
}
|
||||||
@@ -23,7 +23,7 @@ post_update_email_branding_schema = {
|
|||||||
"name": {"type": ["string", "null"]},
|
"name": {"type": ["string", "null"]},
|
||||||
"text": {"type": ["string", "null"]},
|
"text": {"type": ["string", "null"]},
|
||||||
"logo": {"type": ["string", "null"]},
|
"logo": {"type": ["string", "null"]},
|
||||||
"brand_type": {"enum": [e.value for e in BrandType]},
|
"brand_type": {"enum": list(BrandType)},
|
||||||
},
|
},
|
||||||
"required": [],
|
"required": [],
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,7 @@ add_service_data_retention_request = {
|
|||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"days_of_retention": {"type": "integer"},
|
"days_of_retention": {"type": "integer"},
|
||||||
"notification_type": {
|
"notification_type": {"enum": [NotificationType.SMS, NotificationType.EMAIL]},
|
||||||
"enum": [NotificationType.SMS.value, NotificationType.EMAIL.value]
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
"required": ["days_of_retention", "notification_type"],
|
"required": ["days_of_retention", "notification_type"],
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ def format_monthly_template_notification_stats(year, rows):
|
|||||||
stats[formatted_month][str(row.template_id)] = {
|
stats[formatted_month][str(row.template_id)] = {
|
||||||
"name": row.name,
|
"name": row.name,
|
||||||
"type": row.template_type,
|
"type": row.template_type,
|
||||||
"counts": dict.fromkeys([e.value for e in NotificationStatus], 0),
|
"counts": dict.fromkeys(list(NotificationStatus), 0),
|
||||||
}
|
}
|
||||||
stats[formatted_month][str(row.template_id)]["counts"][row.status] += row.count
|
stats[formatted_month][str(row.template_id)]["counts"][row.status] += row.count
|
||||||
|
|
||||||
@@ -83,17 +83,17 @@ def create_zeroed_stats_dicts():
|
|||||||
|
|
||||||
|
|
||||||
def _update_statuses_from_row(update_dict, row):
|
def _update_statuses_from_row(update_dict, row):
|
||||||
if row.status != "cancelled":
|
if row.status != NotificationStatus.CANCELLED:
|
||||||
update_dict["requested"] += row.count
|
update_dict["requested"] += row.count
|
||||||
if row.status in ("delivered", "sent"):
|
if row.status in (NotificationStatus.DELIVERED, NotificationStatus.SENT):
|
||||||
update_dict["delivered"] += row.count
|
update_dict["delivered"] += row.count
|
||||||
elif row.status in (
|
elif row.status in (
|
||||||
"failed",
|
NotificationStatus.FAILED,
|
||||||
"technical-failure",
|
NotificationStatus.TECHNICAL_FAILURE,
|
||||||
"temporary-failure",
|
NotificationStatus.TEMPORARY_FAILURE,
|
||||||
"permanent-failure",
|
NotificationStatus.PERMANENT_FAILURE,
|
||||||
"validation-failed",
|
NotificationStatus.VALIDATION_FAILED,
|
||||||
"virus-scan-failed",
|
NotificationStatus.VIRUS_SCAN_FAILED,
|
||||||
):
|
):
|
||||||
update_dict["failed"] += row.count
|
update_dict["failed"] += row.count
|
||||||
|
|
||||||
|
|||||||
@@ -8,15 +8,15 @@ post_create_template_schema = {
|
|||||||
"title": "payload for POST /service/<uuid:service_id>/template",
|
"title": "payload for POST /service/<uuid:service_id>/template",
|
||||||
"properties": {
|
"properties": {
|
||||||
"name": {"type": "string"},
|
"name": {"type": "string"},
|
||||||
"template_type": {"enum": [e.value for e in TemplateType]},
|
"template_type": {"enum": list(TemplateType)},
|
||||||
"service": uuid,
|
"service": uuid,
|
||||||
"process_type": {"enum": [e.value for e in TemplateProcessType]},
|
"process_type": {"enum": list(TemplateProcessType)},
|
||||||
"content": {"type": "string"},
|
"content": {"type": "string"},
|
||||||
"subject": {"type": "string"},
|
"subject": {"type": "string"},
|
||||||
"created_by": uuid,
|
"created_by": uuid,
|
||||||
"parent_folder_id": uuid,
|
"parent_folder_id": uuid,
|
||||||
},
|
},
|
||||||
"if": {"properties": {"template_type": {"enum": [TemplateType.EMAIL.value]}}},
|
"if": {"properties": {"template_type": {"enum": [TemplateType.EMAIL]}}},
|
||||||
"then": {"required": ["subject"]},
|
"then": {"required": ["subject"]},
|
||||||
"required": ["name", "template_type", "content", "service", "created_by"],
|
"required": ["name", "template_type", "content", "service", "created_by"],
|
||||||
}
|
}
|
||||||
@@ -29,9 +29,9 @@ post_update_template_schema = {
|
|||||||
"properties": {
|
"properties": {
|
||||||
"id": uuid,
|
"id": uuid,
|
||||||
"name": {"type": "string"},
|
"name": {"type": "string"},
|
||||||
"template_type": {"enum": [e.value for e in TemplateType]},
|
"template_type": {"enum": list(TemplateType)},
|
||||||
"service": uuid,
|
"service": uuid,
|
||||||
"process_type": {"enum": [e.value for e in TemplateProcessType]},
|
"process_type": {"enum": list(TemplateProcessType)},
|
||||||
"content": {"type": "string"},
|
"content": {"type": "string"},
|
||||||
"subject": {"type": "string"},
|
"subject": {"type": "string"},
|
||||||
"reply_to": nullable_uuid,
|
"reply_to": nullable_uuid,
|
||||||
|
|||||||
@@ -41,7 +41,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": [e.value for e in TemplateType]},
|
"type": {"enum": list(TemplateType)},
|
||||||
"status": {"type": "string"},
|
"status": {"type": "string"},
|
||||||
"template": template,
|
"template": template,
|
||||||
"body": {"type": "string"},
|
"body": {"type": "string"},
|
||||||
@@ -82,11 +82,11 @@ get_notifications_request = {
|
|||||||
"reference": {"type": "string"},
|
"reference": {"type": "string"},
|
||||||
"status": {
|
"status": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {"enum": [e.value for e in NotificationStatus]},
|
"items": {"enum": list(NotificationStatus)},
|
||||||
},
|
},
|
||||||
"template_type": {
|
"template_type": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {"enum": [e.value for e in TemplateType]},
|
"items": {"enum": list(TemplateType)},
|
||||||
},
|
},
|
||||||
"include_jobs": {"enum": ["true", "True"]},
|
"include_jobs": {"enum": ["true", "True"]},
|
||||||
"older_than": uuid,
|
"older_than": uuid,
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ get_template_by_id_response = {
|
|||||||
"title": "reponse v2/template",
|
"title": "reponse v2/template",
|
||||||
"properties": {
|
"properties": {
|
||||||
"id": uuid,
|
"id": uuid,
|
||||||
"type": {"enum": [e.value for e in TemplateType]},
|
"type": {"enum": list(TemplateType)},
|
||||||
"created_at": {
|
"created_at": {
|
||||||
"format": "date-time",
|
"format": "date-time",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
@@ -62,7 +62,7 @@ post_template_preview_response = {
|
|||||||
"title": "reponse v2/template/{id}/preview",
|
"title": "reponse v2/template/{id}/preview",
|
||||||
"properties": {
|
"properties": {
|
||||||
"id": uuid,
|
"id": uuid,
|
||||||
"type": {"enum": [e.value for e in TemplateType]},
|
"type": {"enum": list(TemplateType)},
|
||||||
"version": {"type": "integer"},
|
"version": {"type": "integer"},
|
||||||
"body": {"type": "string"},
|
"body": {"type": "string"},
|
||||||
"subject": {"type": ["string", "null"]},
|
"subject": {"type": ["string", "null"]},
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ get_all_template_request = {
|
|||||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||||
"description": "request schema for parameters allowed when getting all templates",
|
"description": "request schema for parameters allowed when getting all templates",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {"type": {"enum": [e.value for e in TemplateType]}},
|
"properties": {"type": {"enum": list(TemplateType)}},
|
||||||
"additionalProperties": False,
|
"additionalProperties": False,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -272,13 +272,19 @@ def test_only_normal_api_keys_can_return_job_notifications(
|
|||||||
key_type,
|
key_type,
|
||||||
):
|
):
|
||||||
normal_notification = create_notification(
|
normal_notification = create_notification(
|
||||||
template=sample_template, api_key=sample_api_key, key_type=KeyType.NORMAL
|
template=sample_template,
|
||||||
|
api_key=sample_api_key,
|
||||||
|
key_type=KeyType.NORMAL,
|
||||||
)
|
)
|
||||||
team_notification = create_notification(
|
team_notification = create_notification(
|
||||||
template=sample_template, api_key=sample_team_api_key, key_type=KeyType.TEAM
|
template=sample_template,
|
||||||
|
api_key=sample_team_api_key,
|
||||||
|
key_type=KeyType.TEAM,
|
||||||
)
|
)
|
||||||
test_notification = create_notification(
|
test_notification = create_notification(
|
||||||
template=sample_template, api_key=sample_test_api_key, key_type=KeyType.TEST
|
template=sample_template,
|
||||||
|
api_key=sample_test_api_key,
|
||||||
|
key_type=KeyType.TEST,
|
||||||
)
|
)
|
||||||
|
|
||||||
notification_objs = {
|
notification_objs = {
|
||||||
|
|||||||
@@ -1231,9 +1231,7 @@ def test_default_permissions_are_added_for_user_service(
|
|||||||
str(sample_service.id)
|
str(sample_service.id)
|
||||||
]
|
]
|
||||||
|
|
||||||
assert sorted(i.value for i in PermissionType.defaults()) == sorted(
|
assert sorted(PermissionType.defaults()) == sorted(service_permissions)
|
||||||
service_permissions
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def test_add_existing_user_to_another_service_with_all_permissions(
|
def test_add_existing_user_to_another_service_with_all_permissions(
|
||||||
@@ -1790,7 +1788,7 @@ def test_get_all_notifications_for_service_filters_notifications_when_using_post
|
|||||||
data = {
|
data = {
|
||||||
"page": 1,
|
"page": 1,
|
||||||
"template_type": [TemplateType.SMS],
|
"template_type": [TemplateType.SMS],
|
||||||
"status": ["created", "sending"],
|
"status": [NotificationStatus.CREATED, NotificationStatus.SENDING],
|
||||||
"to": "0855",
|
"to": "0855",
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2103,7 +2101,7 @@ def test_get_detailed_service(
|
|||||||
date(2000, 1, 1), NotificationType.SMS, sample_service, count=1
|
date(2000, 1, 1), NotificationType.SMS, sample_service, count=1
|
||||||
)
|
)
|
||||||
with freeze_time("2000-01-02T12:00:00"):
|
with freeze_time("2000-01-02T12:00:00"):
|
||||||
create_notification(template=sample_template, status="created")
|
create_notification(template=sample_template, status=NotificationStatus.CREATED)
|
||||||
resp = client.get(
|
resp = client.get(
|
||||||
f"/service/{sample_service.id}?detailed=True&today_only={today_only}",
|
f"/service/{sample_service.id}?detailed=True&today_only={today_only}",
|
||||||
headers=[create_admin_authorization_header()],
|
headers=[create_admin_authorization_header()],
|
||||||
@@ -2114,10 +2112,10 @@ def test_get_detailed_service(
|
|||||||
assert service["id"] == str(sample_service.id)
|
assert service["id"] == str(sample_service.id)
|
||||||
assert "statistics" in service.keys()
|
assert "statistics" in service.keys()
|
||||||
assert set(service["statistics"].keys()) == {
|
assert set(service["statistics"].keys()) == {
|
||||||
NotificationType.SMS.value,
|
NotificationType.SMS,
|
||||||
NotificationType.EMAIL.value,
|
NotificationType.EMAIL,
|
||||||
}
|
}
|
||||||
assert service["statistics"][NotificationType.SMS.value] == stats
|
assert service["statistics"][NotificationType.SMS] == stats
|
||||||
|
|
||||||
|
|
||||||
def test_get_services_with_detailed_flag(client, sample_template):
|
def test_get_services_with_detailed_flag(client, sample_template):
|
||||||
@@ -2136,8 +2134,8 @@ def test_get_services_with_detailed_flag(client, sample_template):
|
|||||||
assert data[0]["name"] == "Sample service"
|
assert data[0]["name"] == "Sample service"
|
||||||
assert data[0]["id"] == str(notifications[0].service_id)
|
assert data[0]["id"] == str(notifications[0].service_id)
|
||||||
assert data[0]["statistics"] == {
|
assert data[0]["statistics"] == {
|
||||||
NotificationType.EMAIL.value: {"delivered": 0, "failed": 0, "requested": 0},
|
NotificationType.EMAIL: {"delivered": 0, "failed": 0, "requested": 0},
|
||||||
NotificationType.SMS.value: {"delivered": 0, "failed": 0, "requested": 3},
|
NotificationType.SMS: {"delivered": 0, "failed": 0, "requested": 3},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -2159,8 +2157,8 @@ def test_get_services_with_detailed_flag_excluding_from_test_key(
|
|||||||
data = resp.json["data"]
|
data = resp.json["data"]
|
||||||
assert len(data) == 1
|
assert len(data) == 1
|
||||||
assert data[0]["statistics"] == {
|
assert data[0]["statistics"] == {
|
||||||
NotificationType.EMAIL.value: {"delivered": 0, "failed": 0, "requested": 0},
|
NotificationType.EMAIL: {"delivered": 0, "failed": 0, "requested": 0},
|
||||||
NotificationType.SMS.value: {"delivered": 0, "failed": 0, "requested": 2},
|
NotificationType.SMS: {"delivered": 0, "failed": 0, "requested": 2},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -2229,27 +2227,27 @@ def test_get_detailed_services_groups_by_service(notify_db_session):
|
|||||||
assert len(data) == 2
|
assert len(data) == 2
|
||||||
assert data[0]["id"] == str(service_1.id)
|
assert data[0]["id"] == str(service_1.id)
|
||||||
assert data[0]["statistics"] == {
|
assert data[0]["statistics"] == {
|
||||||
NotificationType.EMAIL.value: {
|
NotificationType.EMAIL: {
|
||||||
NotificationStatus.DELIVERED: 0,
|
"delivered": 0,
|
||||||
NotificationStatus.FAILED: 0,
|
"failed": 0,
|
||||||
"requested": 0,
|
"requested": 0,
|
||||||
},
|
},
|
||||||
NotificationType.SMS.value: {
|
NotificationType.SMS: {
|
||||||
NotificationStatus.DELIVERED: 1,
|
"delivered": 1,
|
||||||
NotificationStatus.FAILED: 0,
|
"failed": 0,
|
||||||
"requested": 3,
|
"requested": 3,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
assert data[1]["id"] == str(service_2.id)
|
assert data[1]["id"] == str(service_2.id)
|
||||||
assert data[1]["statistics"] == {
|
assert data[1]["statistics"] == {
|
||||||
NotificationType.EMAIL.value: {
|
NotificationType.EMAIL: {
|
||||||
NotificationStatus.DELIVERED: 0,
|
"delivered": 0,
|
||||||
NotificationStatus.FAILED: 0,
|
"failed": 0,
|
||||||
"requested": 0,
|
"requested": 0,
|
||||||
},
|
},
|
||||||
NotificationType.SMS.value: {
|
NotificationType.SMS: {
|
||||||
NotificationStatus.DELIVERED: 0,
|
"delivered": 0,
|
||||||
NotificationStatus.FAILED: 0,
|
"failed": 0,
|
||||||
"requested": 1,
|
"requested": 1,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -2274,27 +2272,27 @@ def test_get_detailed_services_includes_services_with_no_notifications(
|
|||||||
assert len(data) == 2
|
assert len(data) == 2
|
||||||
assert data[0]["id"] == str(service_1.id)
|
assert data[0]["id"] == str(service_1.id)
|
||||||
assert data[0]["statistics"] == {
|
assert data[0]["statistics"] == {
|
||||||
NotificationType.EMAIL.value: {
|
NotificationType.EMAIL: {
|
||||||
NotificationStatus.DELIVERED: 0,
|
"delivered": 0,
|
||||||
NotificationStatus.FAILED: 0,
|
"failed": 0,
|
||||||
"requested": 0,
|
"requested": 0,
|
||||||
},
|
},
|
||||||
NotificationType.SMS.value: {
|
NotificationType.SMS: {
|
||||||
NotificationStatus.DELIVERED: 0,
|
"delivered": 0,
|
||||||
NotificationStatus.FAILED: 0,
|
"failed": 0,
|
||||||
"requested": 1,
|
"requested": 1,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
assert data[1]["id"] == str(service_2.id)
|
assert data[1]["id"] == str(service_2.id)
|
||||||
assert data[1]["statistics"] == {
|
assert data[1]["statistics"] == {
|
||||||
NotificationType.EMAIL.value: {
|
NotificationType.EMAIL: {
|
||||||
NotificationStatus.DELIVERED: 0,
|
"delivered": 0,
|
||||||
NotificationStatus.FAILED: 0,
|
"failed": 0,
|
||||||
"requested": 0,
|
"requested": 0,
|
||||||
},
|
},
|
||||||
NotificationType.SMS.value: {
|
NotificationType.SMS: {
|
||||||
NotificationStatus.DELIVERED: 0,
|
"delivered": 0,
|
||||||
NotificationStatus.FAILED: 0,
|
"failed": 0,
|
||||||
"requested": 0,
|
"requested": 0,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -2316,14 +2314,14 @@ def test_get_detailed_services_only_includes_todays_notifications(sample_templat
|
|||||||
|
|
||||||
assert len(data) == 1
|
assert len(data) == 1
|
||||||
assert data[0]["statistics"] == {
|
assert data[0]["statistics"] == {
|
||||||
NotificationType.EMAIL.value: {
|
NotificationType.EMAIL: {
|
||||||
NotificationStatus.DELIVERED: 0,
|
"delivered": 0,
|
||||||
NotificationStatus.FAILED: 0,
|
"failed": 0,
|
||||||
"requested": 0,
|
"requested": 0,
|
||||||
},
|
},
|
||||||
NotificationType.SMS.value: {
|
NotificationType.SMS: {
|
||||||
NotificationStatus.DELIVERED: 0,
|
"delivered": 0,
|
||||||
NotificationStatus.FAILED: 0,
|
"failed": 0,
|
||||||
"requested": 3,
|
"requested": 3,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -2369,14 +2367,14 @@ def test_get_detailed_services_for_date_range(
|
|||||||
)
|
)
|
||||||
|
|
||||||
assert len(data) == 1
|
assert len(data) == 1
|
||||||
assert data[0]["statistics"][NotificationType.EMAIL.value] == {
|
assert data[0]["statistics"][NotificationType.EMAIL] == {
|
||||||
NotificationStatus.DELIVERED: 0,
|
"delivered": 0,
|
||||||
NotificationStatus.FAILED: 0,
|
"failed": 0,
|
||||||
"requested": 0,
|
"requested": 0,
|
||||||
}
|
}
|
||||||
assert data[0]["statistics"][NotificationType.SMS.value] == {
|
assert data[0]["statistics"][NotificationType.SMS] == {
|
||||||
NotificationStatus.DELIVERED: 2,
|
"delivered": 2,
|
||||||
NotificationStatus.FAILED: 0,
|
"failed": 0,
|
||||||
"requested": 2,
|
"requested": 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -265,7 +265,8 @@ def test_populate_annual_billing_with_defaults(
|
|||||||
notify_db_session, notify_api, organization_type, expected_allowance
|
notify_db_session, notify_api, organization_type, expected_allowance
|
||||||
):
|
):
|
||||||
service = create_service(
|
service = create_service(
|
||||||
service_name=organization_type.value, organization_type=organization_type
|
service_name=organization_type,
|
||||||
|
organization_type=organization_type,
|
||||||
)
|
)
|
||||||
|
|
||||||
notify_api.test_cli_runner().invoke(
|
notify_api.test_cli_runner().invoke(
|
||||||
@@ -289,7 +290,8 @@ def test_populate_annual_billing_with_the_previous_years_allowance(
|
|||||||
notify_db_session, notify_api, organization_type, expected_allowance
|
notify_db_session, notify_api, organization_type, expected_allowance
|
||||||
):
|
):
|
||||||
service = create_service(
|
service = create_service(
|
||||||
service_name=organization_type.value, organization_type=organization_type
|
service_name=organization_type,
|
||||||
|
organization_type=organization_type,
|
||||||
)
|
)
|
||||||
|
|
||||||
notify_api.test_cli_runner().invoke(
|
notify_api.test_cli_runner().invoke(
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import pytest
|
import pytest
|
||||||
from flask import json, url_for
|
from flask import json, url_for
|
||||||
|
|
||||||
from app.enums import NotificationType, TemplateType
|
from app.enums import NotificationStatus, NotificationType, TemplateType
|
||||||
from app.utils import DATETIME_FORMAT
|
from app.utils import DATETIME_FORMAT
|
||||||
from tests import create_service_authorization_header
|
from tests import create_service_authorization_header
|
||||||
from tests.app.db import create_notification, create_template
|
from tests.app.db import create_notification, create_template
|
||||||
@@ -284,7 +284,7 @@ def test_get_all_notifications_except_job_notifications_returns_200(
|
|||||||
assert len(json_response["notifications"]) == 2
|
assert len(json_response["notifications"]) == 2
|
||||||
|
|
||||||
assert json_response["notifications"][0]["id"] == str(notification.id)
|
assert json_response["notifications"][0]["id"] == str(notification.id)
|
||||||
assert json_response["notifications"][0]["status"] == "created"
|
assert json_response["notifications"][0]["status"] == NotificationStatus.CREATED
|
||||||
assert json_response["notifications"][0]["template"] == {
|
assert json_response["notifications"][0]["template"] == {
|
||||||
"id": str(notification.template.id),
|
"id": str(notification.template.id),
|
||||||
"uri": notification.template.get_link(),
|
"uri": notification.template.get_link(),
|
||||||
@@ -380,7 +380,7 @@ def test_get_all_notifications_filter_by_template_type(client, sample_service):
|
|||||||
assert len(json_response["notifications"]) == 1
|
assert len(json_response["notifications"]) == 1
|
||||||
|
|
||||||
assert json_response["notifications"][0]["id"] == str(notification.id)
|
assert json_response["notifications"][0]["id"] == str(notification.id)
|
||||||
assert json_response["notifications"][0]["status"] == "created"
|
assert json_response["notifications"][0]["status"] == NotificationStatus.CREATED
|
||||||
assert json_response["notifications"][0]["template"] == {
|
assert json_response["notifications"][0]["template"] == {
|
||||||
"id": str(email_template.id),
|
"id": str(email_template.id),
|
||||||
"uri": notification.template.get_link(),
|
"uri": notification.template.get_link(),
|
||||||
@@ -469,7 +469,11 @@ def test_get_all_notifications_filter_by_status_invalid_status(
|
|||||||
def test_get_all_notifications_filter_by_multiple_statuses(client, sample_template):
|
def test_get_all_notifications_filter_by_multiple_statuses(client, sample_template):
|
||||||
notifications = [
|
notifications = [
|
||||||
create_notification(template=sample_template, status=_status)
|
create_notification(template=sample_template, status=_status)
|
||||||
for _status in ["created", "pending", "sending"]
|
for _status in [
|
||||||
|
NotificationStatus.CREATED,
|
||||||
|
NotificationStatus.PENDING,
|
||||||
|
NotificationStatus.SENDING,
|
||||||
|
]
|
||||||
]
|
]
|
||||||
failed_notification = create_notification(
|
failed_notification = create_notification(
|
||||||
template=sample_template, status="permanent-failure"
|
template=sample_template, status="permanent-failure"
|
||||||
@@ -502,7 +506,8 @@ def test_get_all_notifications_filter_by_multiple_statuses(client, sample_templa
|
|||||||
|
|
||||||
def test_get_all_notifications_filter_by_failed_status(client, sample_template):
|
def test_get_all_notifications_filter_by_failed_status(client, sample_template):
|
||||||
created_notification = create_notification(
|
created_notification = create_notification(
|
||||||
template=sample_template, status="created"
|
template=sample_template,
|
||||||
|
status=NotificationStatus.CREATED,
|
||||||
)
|
)
|
||||||
failed_notifications = [
|
failed_notifications = [
|
||||||
create_notification(template=sample_template, status="failed")
|
create_notification(template=sample_template, status="failed")
|
||||||
@@ -692,6 +697,6 @@ def test_get_all_notifications_renames_letter_statuses(
|
|||||||
noti["type"] == NotificationType.SMS
|
noti["type"] == NotificationType.SMS
|
||||||
or noti["type"] == NotificationType.EMAIL
|
or noti["type"] == NotificationType.EMAIL
|
||||||
):
|
):
|
||||||
assert noti["status"] == "created"
|
assert noti["status"] == NotificationStatus.CREATED
|
||||||
else:
|
else:
|
||||||
pytest.fail()
|
pytest.fail()
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ def test_get_notifications_valid_json(input):
|
|||||||
# multiple invalid statuses
|
# multiple invalid statuses
|
||||||
(["elephant", "giraffe", "cheetah"], []),
|
(["elephant", "giraffe", "cheetah"], []),
|
||||||
# one bad status and one good status
|
# one bad status and one good status
|
||||||
(["elephant"], ["created"]),
|
(["elephant"], [NotificationStatus.CREATED]),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_get_notifications_request_invalid_statuses(invalid_statuses, valid_statuses):
|
def test_get_notifications_request_invalid_statuses(invalid_statuses, valid_statuses):
|
||||||
|
|||||||
Reference in New Issue
Block a user