More cleanup.

Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
This commit is contained in:
Cliff Hill
2024-01-30 16:10:28 -05:00
parent fe69042467
commit b1a53c76ee
4 changed files with 33 additions and 26 deletions

View File

@@ -1,4 +1,5 @@
from strenum import StrEnum # In 3.11 this is in the enum library.
from strenum import StrEnum # In 3.11 this is in the enum library. We will not need
# this external library any more.
class TemplateType(StrEnum):

View File

@@ -1860,7 +1860,9 @@ class InvitedUser(db.Model):
)
permissions = db.Column(db.String, nullable=False)
auth_type = enum_column(AuthType, index=True, nullable=False, default=AuthType.SMS)
folder_permissions = db.Column(JSONB(none_as_null=True), nullable=False, default=list)
folder_permissions = db.Column(
JSONB(none_as_null=True), nullable=False, default=list
)
# would like to have used properties for this but haven't found a way to make them
# play nice with marshmallow yet

View File

@@ -159,27 +159,27 @@ def test_fetch_notification_status_for_service_for_today_and_7_previous_days(
service=service_1, template_type=TemplateType.EMAIL
)
create_ft_notification_status(date(2018, 10, 29), "sms", service_1, count=10)
create_ft_notification_status(date(2018, 10, 25), "sms", service_1, count=8)
create_ft_notification_status(date(2018, 10, 29), NotificationType.SMS, service_1, count=10,)
create_ft_notification_status(date(2018, 10, 25), NotificationType.SMS, service_1, count=8,)
create_ft_notification_status(
date(2018, 10, 29), "sms", service_1, notification_status="created"
date(2018, 10, 29), NotificationType.SMS, service_1, notification_status=NotificationStatus.CREATED,
)
create_ft_notification_status(date(2018, 10, 29), "email", service_1, count=3)
create_ft_notification_status(date(2018, 10, 29), NotificationType.EMAIL, service_1, count=3,)
create_notification(sms_template, created_at=datetime(2018, 10, 31, 11, 0, 0))
create_notification(sms_template_2, created_at=datetime(2018, 10, 31, 11, 0, 0))
create_notification(
sms_template, created_at=datetime(2018, 10, 31, 12, 0, 0), status="delivered"
sms_template, created_at=datetime(2018, 10, 31, 12, 0, 0), status=NotificationStatus.DELIVERED,
)
create_notification(
email_template, created_at=datetime(2018, 10, 31, 13, 0, 0), status="delivered"
email_template, created_at=datetime(2018, 10, 31, 13, 0, 0), status=NotificationStatus.DELIVERED,
)
# too early, shouldn't be included
create_notification(
service_1.templates[0],
created_at=datetime(2018, 10, 30, 12, 0, 0),
status="delivered",
status=NotificationStatus.DELIVERED,
)
results = sorted(
@@ -191,16 +191,16 @@ def test_fetch_notification_status_for_service_for_today_and_7_previous_days(
assert len(results) == 3
assert results[0].notification_type == "email"
assert results[0].status == "delivered"
assert results[0].notification_type == NotificationType.EMAIL
assert results[0].status == NotificationStatus.DELIVERED
assert results[0].count == 4
assert results[1].notification_type == "sms"
assert results[1].status == "created"
assert results[1].notification_type == NotificationType.SMS
assert results[1].status == NotificationStatus.CREATED
assert results[1].count == 3
assert results[2].notification_type == "sms"
assert results[2].status == "delivered"
assert results[2].notification_type == NotificationType.SMS
assert results[2].status == NotificationStatus.DELIVERED
assert results[2].count == 19

View File

@@ -27,10 +27,14 @@ from app.dao.services_dao import dao_add_user_to_service, dao_create_service
from app.dao.templates_dao import dao_create_template, dao_update_template
from app.dao.users_dao import save_model_user
from app.enums import (
JobStatus,
KeyType,
NotificationStatus,
NotificationType,
OrganizationType,
RecipientType,
ServicePermissionType,
TemplateProcessType,
TemplateType,
)
from app.models import (
@@ -204,7 +208,7 @@ def create_template(
hidden=False,
archived=False,
folder=None,
process_type="normal",
process_type=TemplateProcessType.NORMAL,
contact_block_id=None,
):
data = {
@@ -235,7 +239,7 @@ def create_notification(
job=None,
job_row_number=None,
to_field=None,
status="created",
status=NotificationStatus.CREATED,
reference=None,
created_at=None,
sent_at=None,
@@ -326,7 +330,7 @@ def create_notification_history(
template=None,
job=None,
job_row_number=None,
status="created",
status=NotificationStatus.CREATED,
reference=None,
created_at=None,
sent_at=None,
@@ -390,7 +394,7 @@ def create_job(
template,
notification_count=1,
created_at=None,
job_status="pending",
job_status=JobStatus.PENDING,
scheduled_for=None,
processing_started=None,
processing_finished=None,
@@ -681,12 +685,12 @@ def create_ft_billing(
def create_ft_notification_status(
local_date,
notification_type="sms",
notification_type=NotificationType.SMS,
service=None,
template=None,
job=None,
key_type="normal",
notification_status="delivered",
key_type=KeyType.NORMAL,
notification_status=NotificationStatus.DELIVERED,
count=1,
):
if job:
@@ -842,7 +846,7 @@ def ses_notification_callback():
def create_service_data_retention(
service, notification_type="sms", days_of_retention=3
service, notification_type=NotificationType.SMS, days_of_retention=3
):
data_retention = insert_service_data_retention(
service_id=service.id,
@@ -925,7 +929,7 @@ def set_up_usage_data(start_date):
# service with emails only:
service_with_emails = create_service(service_name="b - emails")
email_template = create_template(service=service_with_emails, template_type="email")
email_template = create_template(service=service_with_emails, template_type=TemplateType.EMAIL)
org_2 = create_organization(
name="Org for {}".format(service_with_emails.name),
)
@@ -951,7 +955,7 @@ def set_up_usage_data(start_date):
billing_reference="sms billing reference",
)
sms_template = create_template(
service=service_with_sms_without_org, template_type="sms"
service=service_with_sms_without_org, template_type=TemplateType.SMS
)
create_annual_billing(
service_id=service_with_sms_without_org.id,
@@ -971,7 +975,7 @@ def set_up_usage_data(start_date):
service_name="e - sms within allowance"
)
sms_template_2 = create_template(
service=service_with_sms_within_allowance, template_type="sms"
service=service_with_sms_within_allowance, template_type=TemplateType.SMS
)
create_annual_billing(
service_id=service_with_sms_within_allowance.id,