mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-23 17:01:35 -05:00
This morning we raise a ParseError for a bad date format for the DateReceived attribute on the /notifications/receive/mmg request.
This PR tries to parse the date, if that throws an error return now as the datereceived. This will at least allow the message to be persisted. Typically the DateReceived, provider_date, and the created_at date in the inbound_sms table are within a second of each other.
This commit is contained in:
@@ -4,6 +4,7 @@ from unittest.mock import call
|
||||
|
||||
import pytest
|
||||
from flask import json
|
||||
from freezegun import freeze_time
|
||||
|
||||
from app.notifications.receive_notifications import (
|
||||
format_mmg_message,
|
||||
@@ -216,6 +217,11 @@ def test_format_mmg_datetime(provider_date, expected_output):
|
||||
assert format_mmg_datetime(provider_date) == expected_output
|
||||
|
||||
|
||||
@freeze_time('2020-05-14 14:30:00')
|
||||
def test_format_mmg_datetime_returns_now_if_cannot_parse_date():
|
||||
assert format_mmg_datetime('13-05-2020 08%3A37%3A43') == datetime.utcnow()
|
||||
|
||||
|
||||
def test_create_inbound_mmg_sms_object(sample_service_full_permissions):
|
||||
data = {
|
||||
'Message': 'hello+there+%F0%9F%93%A9',
|
||||
|
||||
Reference in New Issue
Block a user