mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-24 16:23:44 -04:00
@@ -33,7 +33,6 @@ from app.utils import (
|
|||||||
class TemplateType(Enum):
|
class TemplateType(Enum):
|
||||||
SMS = "sms"
|
SMS = "sms"
|
||||||
EMAIL = "email"
|
EMAIL = "email"
|
||||||
LETTER = "letter"
|
|
||||||
|
|
||||||
|
|
||||||
class NotificationType(Enum):
|
class NotificationType(Enum):
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ from collections import defaultdict
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from app.dao.date_util import get_months_for_financial_year
|
from app.dao.date_util import get_months_for_financial_year
|
||||||
from app.models import NOTIFICATION_STATUS_TYPES, NOTIFICATION_TYPES
|
from app.models import NOTIFICATION_STATUS_TYPES, TemplateType
|
||||||
|
|
||||||
|
|
||||||
def format_statistics(statistics):
|
def format_statistics(statistics):
|
||||||
@@ -40,7 +40,7 @@ def format_admin_stats(statistics):
|
|||||||
|
|
||||||
def create_stats_dict():
|
def create_stats_dict():
|
||||||
stats_dict = {}
|
stats_dict = {}
|
||||||
for template in NOTIFICATION_TYPES:
|
for template in TemplateType:
|
||||||
stats_dict[template] = {}
|
stats_dict[template] = {}
|
||||||
|
|
||||||
for status in ("total", "test-key"):
|
for status in ("total", "test-key"):
|
||||||
@@ -78,7 +78,7 @@ def format_monthly_template_notification_stats(year, rows):
|
|||||||
def create_zeroed_stats_dicts():
|
def create_zeroed_stats_dicts():
|
||||||
return {
|
return {
|
||||||
template_type: {status: 0 for status in ("requested", "delivered", "failed")}
|
template_type: {status: 0 for status in ("requested", "delivered", "failed")}
|
||||||
for template_type in NOTIFICATION_TYPES
|
for template_type in TemplateType
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -103,7 +103,7 @@ def create_empty_monthly_notification_status_stats_dict(year):
|
|||||||
# nested dicts - data[month][template type][status] = count
|
# nested dicts - data[month][template type][status] = count
|
||||||
return {
|
return {
|
||||||
start.strftime("%Y-%m"): {
|
start.strftime("%Y-%m"): {
|
||||||
template_type: defaultdict(int) for template_type in NOTIFICATION_TYPES
|
template_type: defaultdict(int) for template_type in TemplateType
|
||||||
}
|
}
|
||||||
for start in utc_month_starts
|
for start in utc_month_starts
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from app.models import TEMPLATE_PROCESS_TYPE, TEMPLATE_TYPES
|
from app.models import TEMPLATE_PROCESS_TYPE, TemplateType
|
||||||
from app.schema_validation.definitions import nullable_uuid, uuid
|
from app.schema_validation.definitions import nullable_uuid, uuid
|
||||||
|
|
||||||
post_create_template_schema = {
|
post_create_template_schema = {
|
||||||
@@ -8,7 +8,7 @@ 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": TEMPLATE_TYPES},
|
"template_type": {"enum": [e.value for e in TemplateType]},
|
||||||
"service": uuid,
|
"service": uuid,
|
||||||
"process_type": {"enum": TEMPLATE_PROCESS_TYPE},
|
"process_type": {"enum": TEMPLATE_PROCESS_TYPE},
|
||||||
"content": {"type": "string"},
|
"content": {"type": "string"},
|
||||||
@@ -29,7 +29,7 @@ post_update_template_schema = {
|
|||||||
"properties": {
|
"properties": {
|
||||||
"id": uuid,
|
"id": uuid,
|
||||||
"name": {"type": "string"},
|
"name": {"type": "string"},
|
||||||
"template_type": {"enum": TEMPLATE_TYPES},
|
"template_type": {"enum": [e.value for e in TemplateType]},
|
||||||
"service": uuid,
|
"service": uuid,
|
||||||
"process_type": {"enum": TEMPLATE_PROCESS_TYPE},
|
"process_type": {"enum": TEMPLATE_PROCESS_TYPE},
|
||||||
"content": {"type": "string"},
|
"content": {"type": "string"},
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from app.models import NOTIFICATION_STATUS_TYPES, NOTIFICATION_TYPES
|
from app.models import NOTIFICATION_STATUS_TYPES, TemplateType
|
||||||
from app.schema_validation.definitions import personalisation, uuid
|
from app.schema_validation.definitions import personalisation, uuid
|
||||||
|
|
||||||
template = {
|
template = {
|
||||||
@@ -81,7 +81,10 @@ get_notifications_request = {
|
|||||||
"properties": {
|
"properties": {
|
||||||
"reference": {"type": "string"},
|
"reference": {"type": "string"},
|
||||||
"status": {"type": "array", "items": {"enum": NOTIFICATION_STATUS_TYPES}},
|
"status": {"type": "array", "items": {"enum": NOTIFICATION_STATUS_TYPES}},
|
||||||
"template_type": {"type": "array", "items": {"enum": NOTIFICATION_TYPES}},
|
"template_type": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {"enum": [e.value for e in TemplateType]},
|
||||||
|
},
|
||||||
"include_jobs": {"enum": ["true", "True"]},
|
"include_jobs": {"enum": ["true", "True"]},
|
||||||
"older_than": uuid,
|
"older_than": uuid,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from app.models import TEMPLATE_TYPES
|
from app.models import TemplateType
|
||||||
from app.schema_validation.definitions import personalisation, uuid
|
from app.schema_validation.definitions import personalisation, uuid
|
||||||
|
|
||||||
get_template_by_id_request = {
|
get_template_by_id_request = {
|
||||||
@@ -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": TEMPLATE_TYPES},
|
"type": {"enum": [e.value for e in 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": TEMPLATE_TYPES},
|
"type": {"enum": [e.value for e in TemplateType]},
|
||||||
"version": {"type": "integer"},
|
"version": {"type": "integer"},
|
||||||
"body": {"type": "string"},
|
"body": {"type": "string"},
|
||||||
"subject": {"type": ["string", "null"]},
|
"subject": {"type": ["string", "null"]},
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
from app.models import TEMPLATE_TYPES
|
from app.models import TemplateType
|
||||||
from app.v2.template.template_schemas import get_template_by_id_response as template
|
from app.v2.template.template_schemas import get_template_by_id_response as template
|
||||||
|
|
||||||
get_all_template_request = {
|
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": TEMPLATE_TYPES}},
|
"properties": {"type": {"enum": [e.value for e in TemplateType]}},
|
||||||
"additionalProperties": False,
|
"additionalProperties": False,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ from app.models import (
|
|||||||
KEY_TYPE_NORMAL,
|
KEY_TYPE_NORMAL,
|
||||||
KEY_TYPE_TEAM,
|
KEY_TYPE_TEAM,
|
||||||
KEY_TYPE_TEST,
|
KEY_TYPE_TEST,
|
||||||
NOTIFICATION_TYPES,
|
|
||||||
FactBilling,
|
FactBilling,
|
||||||
FactNotificationStatus,
|
FactNotificationStatus,
|
||||||
Notification,
|
Notification,
|
||||||
@@ -109,7 +108,7 @@ def test_create_nightly_notification_status_triggers_relevant_tasks(
|
|||||||
"app.celery.reporting_tasks.create_nightly_notification_status_for_service_and_day"
|
"app.celery.reporting_tasks.create_nightly_notification_status_for_service_and_day"
|
||||||
).apply_async
|
).apply_async
|
||||||
|
|
||||||
for notification_type in NOTIFICATION_TYPES:
|
for notification_type in NotificationType:
|
||||||
template = create_template(sample_service, template_type=notification_type)
|
template = create_template(sample_service, template_type=notification_type)
|
||||||
create_notification(template=template, created_at=notification_date)
|
create_notification(template=template, created_at=notification_date)
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ from app.models import (
|
|||||||
KEY_TYPE_TEAM,
|
KEY_TYPE_TEAM,
|
||||||
KEY_TYPE_TEST,
|
KEY_TYPE_TEST,
|
||||||
NOTIFICATION_STATUS_TYPES_COMPLETED,
|
NOTIFICATION_STATUS_TYPES_COMPLETED,
|
||||||
SERVICE_PERMISSION_TYPES,
|
|
||||||
ApiKey,
|
ApiKey,
|
||||||
GuestListRecipientType,
|
GuestListRecipientType,
|
||||||
InvitedUser,
|
InvitedUser,
|
||||||
@@ -237,7 +236,7 @@ def sample_service(sample_user):
|
|||||||
def _sample_service_full_permissions(notify_db_session):
|
def _sample_service_full_permissions(notify_db_session):
|
||||||
service = create_service(
|
service = create_service(
|
||||||
service_name="sample service full permissions",
|
service_name="sample service full permissions",
|
||||||
service_permissions=set(SERVICE_PERMISSION_TYPES),
|
service_permissions=set(ServicePermissionType),
|
||||||
check_if_service_exists=True,
|
check_if_service_exists=True,
|
||||||
)
|
)
|
||||||
create_inbound_number("12345", service_id=service.id)
|
create_inbound_number("12345", service_id=service.id)
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ from datetime import date, datetime
|
|||||||
import pytest
|
import pytest
|
||||||
from freezegun import freeze_time
|
from freezegun import freeze_time
|
||||||
|
|
||||||
from app.models import UPLOAD_DOCUMENT
|
from app.models import ServicePermissionType
|
||||||
from app.utils import (
|
from app.utils import (
|
||||||
format_sequential_number,
|
format_sequential_number,
|
||||||
get_midnight_for_day_before,
|
get_midnight_for_day_before,
|
||||||
@@ -89,7 +89,9 @@ def test_get_uuid_string_or_none():
|
|||||||
|
|
||||||
|
|
||||||
def test_get_public_notify_type_text():
|
def test_get_public_notify_type_text():
|
||||||
assert get_public_notify_type_text(UPLOAD_DOCUMENT) == "document"
|
assert (
|
||||||
|
get_public_notify_type_text(ServicePermissionType.UPLOAD_DOCUMENT) == "document"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
# This method is used for simulating bulk sends. We use localstack and run on a developer's machine to do the
|
# This method is used for simulating bulk sends. We use localstack and run on a developer's machine to do the
|
||||||
|
|||||||
Reference in New Issue
Block a user