mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-03 01:41:05 -05:00
Add error handling for possible string/datetime created at stamps
This commit is contained in:
@@ -103,8 +103,19 @@ def dao_create_notification(notification):
|
||||
orig_time = notification.created_at
|
||||
|
||||
now_time = utc_now()
|
||||
print(hilite(f"original time: {orig_time} - {type(orig_time)} \n now time: {now_time} - {type(now_time)}"))
|
||||
diff_time = now_time - datetime.strptime(orig_time, "%Y-%m-%D-%H-%M-%S")
|
||||
print(
|
||||
hilite(
|
||||
f"original time: {orig_time} - {type(orig_time)} \n now time: {now_time} - {type(now_time)}"
|
||||
)
|
||||
)
|
||||
try:
|
||||
diff_time = now_time - orig_time
|
||||
except TypeError:
|
||||
try:
|
||||
orig_time = datetime.strptime(orig_time, "%Y-%m-%dT%H:%M:%S.%fZ")
|
||||
except ValueError:
|
||||
orig_time = datetime.strptime(orig_time, "%Y-%m-%d")
|
||||
diff_time = now_time - orig_time
|
||||
current_app.logger.error(
|
||||
f"dao_create_notification orig created at: {orig_time} and now created at: {now_time}"
|
||||
)
|
||||
|
||||
@@ -103,7 +103,6 @@ def test_create_nightly_notification_status_triggers_relevant_tasks(
|
||||
mock_celery = mocker.patch(
|
||||
"app.celery.reporting_tasks.create_nightly_notification_status_for_service_and_day"
|
||||
).apply_async
|
||||
|
||||
for notification_type in NotificationType:
|
||||
template = create_template(sample_service, template_type=notification_type)
|
||||
create_notification(template=template, created_at=notification_date)
|
||||
|
||||
Reference in New Issue
Block a user