From 2e9cecd3854eb19db804be45298c6f82d1cd4878 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Mon, 18 Sep 2017 11:00:21 +0100 Subject: [PATCH] Confirm no delivery estimate for emails and SMS Only letters have a delivery estimate (which we calculate). This commit adds a test to make sure this remains the case. --- .../notifications/test_get_notifications.py | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/app/v2/notifications/test_get_notifications.py b/tests/app/v2/notifications/test_get_notifications.py index 351b2c82f..814e6dd6c 100644 --- a/tests/app/v2/notifications/test_get_notifications.py +++ b/tests/app/v2/notifications/test_get_notifications.py @@ -9,6 +9,11 @@ from tests.app.db import ( create_template, create_service) +from tests.app.conftest import ( + sample_notification, + sample_email_notification, +) + @pytest.mark.parametrize('billable_units, provider', [ (1, 'mmg'), @@ -233,6 +238,26 @@ def test_get_notification_adds_delivery_estimate_for_letters( assert json_response['estimated_delivery'] == estimated_delivery +@pytest.mark.parametrize('notification_mock', [ + sample_notification, + sample_email_notification, +]) +def test_get_notification_doesnt_have_delivery_estimate_for_non_letters( + client, + notify_db, + notify_db_session, + notification_mock, +): + mocked_notification = notification_mock(notify_db, notify_db_session) + auth_header = create_authorization_header(service_id=mocked_notification.service_id) + response = client.get( + path='/v2/notifications/{}'.format(mocked_notification.id), + headers=[('Content-Type', 'application/json'), auth_header] + ) + assert response.status_code == 200 + assert 'estimated_delivery' not in json.loads(response.get_data(as_text=True)) + + def test_get_all_notifications_returns_200(client, sample_template): notifications = [create_notification(template=sample_template) for _ in range(2)] notification = notifications[-1]