Return delivery estimate for letter notifications

> For get all or get one letter the response needs to be updated so that
> it looks similar to admin app.
>
> status: created|sending --> received letter
> new column: `estimated delivery date`: derived from created at date.
> (see how the admin app is doing it)
>
> NOTE:
> At the moment we only have 2 statuses for a letter created and
> sending, but we will want to have other internal statuses that make
> sense to the Notify team but not our services. When we know those
> statuses the status map will be updated at that point.

– https://www.pivotaltracker.com/story/show/150512525

This commit implements the date (not status) part of this story.
This commit is contained in:
Chris Hill-Scott
2017-09-11 14:16:04 +01:00
parent 0029a0cc0f
commit 29a962060f
3 changed files with 38 additions and 7 deletions

View File

@@ -1,4 +1,4 @@
import datetime
import pytest
from flask import json
@@ -207,6 +207,32 @@ def test_get_notification_by_id_invalid_id(client, sample_notification, id):
}
@pytest.mark.parametrize('created_at_month, estimated_delivery', [
(
12, '2000-12-06T16:00:00.000000Z', # 4pm GMT in winter
),
(
6, '2000-06-05T15:00:00.000000Z', # 4pm BST in summer
),
])
def test_get_notification_adds_delivery_estimate_for_letters(
client,
sample_letter_notification,
created_at_month,
estimated_delivery,
):
sample_letter_notification.created_at = datetime.date(2000, created_at_month, 1)
auth_header = create_authorization_header(service_id=sample_letter_notification.service_id)
response = client.get(
path='/v2/notifications/{}'.format(sample_letter_notification.id),
headers=[('Content-Type', 'application/json'), auth_header]
)
json_response = json.loads(response.get_data(as_text=True))
assert response.status_code == 200
assert json_response['estimated_delivery'] == estimated_delivery
def test_get_all_notifications_returns_200(client, sample_template):
notifications = [create_notification(template=sample_template) for _ in range(2)]
notification = notifications[-1]