Notification_type is a required parameter, admin app always passes it in.

Normalise for notificaiton type.
Throw InvalidRequest exception is the notification type is invalid.
This commit is contained in:
Rebecca Law
2018-03-07 18:13:40 +00:00
committed by Chris Hill-Scott
parent 5f25fc0db4
commit e3a75d1b7d
4 changed files with 62 additions and 46 deletions

View File

@@ -1914,13 +1914,15 @@ def test_get_template_usage_by_month_returns_two_templates(
assert resp_json[2]["is_precompiled_letter"] is False
def test_search_for_notification_by_to_field(client, notify_db, notify_db_session):
create_notification = partial(create_sample_notification, notify_db, notify_db_session)
notification1 = create_notification(to_field='+447700900855', normalised_to='447700900855')
notification2 = create_notification(to_field='jack@gmail.com', normalised_to='jack@gmail.com')
def test_search_for_notification_by_to_field(client, sample_template, sample_email_template):
notification1 = create_notification(template=sample_template, to_field='+447700900855',
normalised_to='447700900855')
notification2 = create_notification(template=sample_email_template, to_field='jack@gmail.com',
normalised_to='jack@gmail.com')
response = client.get(
'/service/{}/notifications?to={}'.format(notification1.service_id, 'jack@gmail.com'),
'/service/{}/notifications?to={}&template_type={}'.format(notification1.service_id, 'jack@gmail.com', 'email'),
headers=[create_authorization_header()]
)
notifications = json.loads(response.get_data(as_text=True))['notifications']
@@ -1938,7 +1940,7 @@ def test_search_for_notification_by_to_field_return_empty_list_if_there_is_no_ma
create_notification(to_field='jack@gmail.com')
response = client.get(
'/service/{}/notifications?to={}'.format(notification1.service_id, '+447700900800'),
'/service/{}/notifications?to={}&template_type={}'.format(notification1.service_id, '+447700900800', 'sms'),
headers=[create_authorization_header()]
)
notifications = json.loads(response.get_data(as_text=True))['notifications']
@@ -1955,7 +1957,7 @@ def test_search_for_notification_by_to_field_return_multiple_matches(client, not
notification4 = create_notification(to_field='jack@gmail.com', normalised_to='jack@gmail.com')
response = client.get(
'/service/{}/notifications?to={}'.format(notification1.service_id, '+447700900855'),
'/service/{}/notifications?to={}&template_type={}'.format(notification1.service_id, '+447700900855', 'sms'),
headers=[create_authorization_header()]
)
notifications = json.loads(response.get_data(as_text=True))['notifications']
@@ -2049,8 +2051,8 @@ def test_search_for_notification_by_to_field_filters_by_status(client, notify_db
create_notification(status='sending')
response = client.get(
'/service/{}/notifications?to={}&status={}'.format(
notification1.service_id, '+447700900855', 'delivered'
'/service/{}/notifications?to={}&status={}&template_type={}'.format(
notification1.service_id, '+447700900855', 'delivered', 'sms'
),
headers=[create_authorization_header()]
)
@@ -2074,8 +2076,8 @@ def test_search_for_notification_by_to_field_filters_by_statuses(client, notify_
notification2 = create_notification(status='sending')
response = client.get(
'/service/{}/notifications?to={}&status={}&status={}'.format(
notification1.service_id, '+447700900855', 'delivered', 'sending'
'/service/{}/notifications?to={}&status={}&status={}&template_type={}'.format(
notification1.service_id, '+447700900855', 'delivered', 'sending', 'sms'
),
headers=[create_authorization_header()]
)
@@ -2104,8 +2106,8 @@ def test_search_for_notification_by_to_field_returns_content(
)
response = client.get(
'/service/{}/notifications?to={}'.format(
sample_template_with_placeholders.service_id, '+447700900855'
'/service/{}/notifications?to={}&template_type={}'.format(
sample_template_with_placeholders.service_id, '+447700900855', 'sms'
),
headers=[create_authorization_header()]
)
@@ -2225,8 +2227,8 @@ def test_search_for_notification_by_to_field_returns_personlisation(
)
response = client.get(
'/service/{}/notifications?to={}'.format(
sample_template_with_placeholders.service_id, '+447700900855'
'/service/{}/notifications?to={}&template_type={}'.format(
sample_template_with_placeholders.service_id, '+447700900855', 'sms'
),
headers=[create_authorization_header()]
)