Cleaning up tests.

Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
This commit is contained in:
Cliff Hill
2024-01-16 14:46:17 -05:00
parent 9523cc1d97
commit 8c6046b03b
33 changed files with 268 additions and 315 deletions

View File

@@ -408,7 +408,7 @@ def _query_for_billing_data(notification_type, start_date, end_date, service):
func.count().label("notifications_sent"),
)
.filter(
NotificationAllTimeView.status.in_(NotificationStatus.sent_emails),
NotificationAllTimeView.status.in_(NotificationStatus.sent_email_types),
NotificationAllTimeView.key_type.in_((KeyType.NORMAL, KeyType.TEAM)),
NotificationAllTimeView.created_at >= start_date,
NotificationAllTimeView.created_at < end_date,
@@ -440,7 +440,9 @@ def _query_for_billing_data(notification_type, start_date, end_date, service):
func.count().label("notifications_sent"),
)
.filter(
NotificationAllTimeView.status.in_(NotificationStatus.billable_sms),
NotificationAllTimeView.status.in_(
NotificationStatus.billable_sms_types
),
NotificationAllTimeView.key_type.in_((KeyType.NORMAL, KeyType.TEAM)),
NotificationAllTimeView.created_at >= start_date,
NotificationAllTimeView.created_at < end_date,

View File

@@ -155,7 +155,7 @@ def send_email_to_provider(notification):
def update_notification_to_sending(notification, provider):
notification.sent_at = datetime.utcnow()
notification.sent_by = provider.name
if notification.status not in NotificationStatus.completed:
if notification.status not in NotificationStatus.completed_types:
notification.status = NotificationStatus.SENDING
dao_update_notification(notification)

View File

@@ -52,7 +52,7 @@ class NotificationStatus(Enum):
VIRUS_SCAN_FAILED = "virus-scan-failed"
@property
def failed(self) -> tuple["NotificationStatus", ...]:
def failed_types(self) -> tuple["NotificationStatus", ...]:
cls = type(self)
return (
cls.TECHNICAL_FAILURE,
@@ -63,7 +63,7 @@ class NotificationStatus(Enum):
)
@property
def completed(self) -> tuple["NotificationStatus", ...]:
def completed_types(self) -> tuple["NotificationStatus", ...]:
cls = type(self)
return (
cls.SENT,
@@ -76,12 +76,12 @@ class NotificationStatus(Enum):
)
@property
def success(self) -> tuple["NotificationStatus", ...]:
def success_types(self) -> tuple["NotificationStatus", ...]:
cls = type(self)
return (cls.SENT, cls.DELIVERED)
@property
def billable(self) -> tuple["NotificationStatus", ...]:
def billable_types(self) -> tuple["NotificationStatus", ...]:
cls = type(self)
return (
cls.SENDING,
@@ -94,7 +94,7 @@ class NotificationStatus(Enum):
)
@property
def billable_sms(self) -> tuple["NotificationStatus", ...]:
def billable_sms_types(self) -> tuple["NotificationStatus", ...]:
cls = type(self)
return (
cls.SENDING,
@@ -106,7 +106,7 @@ class NotificationStatus(Enum):
)
@property
def sent_emails(self) -> tuple["NotificationStatus", ...]:
def sent_email_types(self) -> tuple["NotificationStatus", ...]:
cls = type(self)
return (
cls.SENDING,
@@ -116,7 +116,7 @@ class NotificationStatus(Enum):
)
@property
def non_billable(self) -> tuple["NotificationStatus", ...]:
def non_billable_types(self) -> tuple["NotificationStatus", ...]:
self._non_billable: tuple["NotificationStatus", ...]
try:
return self._non_billable

View File

@@ -1581,7 +1581,7 @@ class Notification(db.Model):
self._personalisation = encryption.encrypt(personalisation or {})
def completed_at(self):
if self.status in NotificationStatus.completed:
if self.status in NotificationStatus.completed_types:
return self.updated_at.strftime(DATETIME_FORMAT)
return None
@@ -1621,7 +1621,7 @@ class Notification(db.Model):
def _substitute_status_str(_status):
return (
NotificationStatus.failed
NotificationStatus.failed_types
if _status == NotificationStatus.FAILED
else [_status]
)