Skip to content

Commit

Permalink
Updated callback v3 data
Browse files Browse the repository at this point in the history
  • Loading branch information
k-macmillan committed Oct 1, 2024
1 parent 74fc31d commit b51ecf0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 20 deletions.
7 changes: 3 additions & 4 deletions app/celery/service_callback_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,17 +291,16 @@ def create_delivery_status_callback_data_v3(notification: Notification) -> dict[
from app import DATETIME_FORMAT # Circular import

data = {
'notification_id': str(notification.id),
'id': str(notification.id),
'reference': notification.client_reference,
'to': notification.to,
'status': notification.status,
'created_at': notification.created_at.strftime(DATETIME_FORMAT),
'updated_at': notification.updated_at.strftime(DATETIME_FORMAT) if notification.updated_at else None,
'completed_at': notification.updated_at.strftime(DATETIME_FORMAT) if notification.updated_at else None,
'sent_at': notification.sent_at.strftime(DATETIME_FORMAT) if notification.sent_at else None,
'notification_type': notification.notification_type,
'callback_url': notification.callback_url,
'provider': notification.sent_by,
'status_reason': notification.status_reason,
'provider': notification.sent_by,
'provider_payload': None,
}

Expand Down
29 changes: 13 additions & 16 deletions tests/app/celery/test_service_callback_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,19 +543,16 @@ def test_create_delivery_status_callback_data_v3(
sample_notification,
):
notification: Notification = sample_notification()
with pytest.raises(AttributeError):
# Remove with statement and reduce indent when callback_url is implemented
data = create_delivery_status_callback_data_v3(notification)

assert data['notification_id'] == notification.id
assert data['reference'] == notification.client_reference
assert data['to'] == notification.to
assert data['status'] == notification.status
assert data['created_at'] == notification.created_at.strftime(DATETIME_FORMAT)
assert data['updated_at'] is None
assert data['sent_at'] is None
assert data['notification_type'] == notification.notification_type
assert data['callback_url'] == notification.callback_url
assert data['provider'] == notification.sent_by
assert data['status_reason'] == notification.status_reason
assert data['provider_payload'] is None
data = create_delivery_status_callback_data_v3(notification)

assert data['id'] == str(notification.id)
assert data['reference'] == notification.client_reference
assert data['to'] == notification.to
assert data['status'] == notification.status
assert data['created_at'] == notification.created_at.strftime(DATETIME_FORMAT)
assert data['completed_at'] is None
assert data['sent_at'] is None
assert data['notification_type'] == notification.notification_type
assert data['status_reason'] == notification.status_reason
assert data['provider'] == notification.sent_by
assert data['provider_payload'] is None

0 comments on commit b51ecf0

Please sign in to comment.