mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-11 09:27:56 -04:00
fix or remove skipped tests
This commit is contained in:
@@ -2552,148 +2552,6 @@ def test_get_detailed_services_for_date_range(
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.skip(
|
||||
reason="We can't search on recipient if recipient is not kept in the db"
|
||||
)
|
||||
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(
|
||||
f"/service/{notification1.service_id}/notifications?to={'jack@gmail.com'}"
|
||||
f"&template_type={TemplateType.EMAIL}",
|
||||
headers=[create_admin_authorization_header()],
|
||||
)
|
||||
notifications = json.loads(response.get_data(as_text=True))["notifications"]
|
||||
|
||||
assert response.status_code == 200
|
||||
assert len(notifications) == 1
|
||||
assert str(notification2.id) == notifications[0]["id"]
|
||||
|
||||
|
||||
@pytest.mark.skip(
|
||||
reason="We can't search on recipient if recipient is not kept in the db"
|
||||
)
|
||||
def test_search_for_notification_by_to_field_return_empty_list_if_there_is_no_match(
|
||||
client, sample_template, sample_email_template
|
||||
):
|
||||
notification1 = create_notification(sample_template, to_field="+447700900855")
|
||||
create_notification(sample_email_template, to_field="jack@gmail.com")
|
||||
|
||||
response = client.get(
|
||||
f"/service/{notification1.service_id}/notifications?"
|
||||
f"to={+447700900800}&template_type={TemplateType.SMS}",
|
||||
headers=[create_admin_authorization_header()],
|
||||
)
|
||||
notifications = json.loads(response.get_data(as_text=True))["notifications"]
|
||||
|
||||
assert response.status_code == 200
|
||||
assert len(notifications) == 0
|
||||
|
||||
|
||||
@pytest.mark.skip(
|
||||
reason="We can't search on recipient if recipient is not kept in the db"
|
||||
)
|
||||
def test_search_for_notification_by_to_field_return_multiple_matches(
|
||||
client, sample_template, sample_email_template
|
||||
):
|
||||
notification1 = create_notification(
|
||||
sample_template,
|
||||
to_field="+447700900855",
|
||||
normalised_to="447700900855",
|
||||
)
|
||||
notification2 = create_notification(
|
||||
sample_template,
|
||||
to_field=" +44 77009 00855 ",
|
||||
normalised_to="447700900855",
|
||||
)
|
||||
notification3 = create_notification(
|
||||
sample_template,
|
||||
to_field="+44770 0900 855",
|
||||
normalised_to="447700900855",
|
||||
)
|
||||
notification4 = create_notification(
|
||||
sample_email_template,
|
||||
to_field="jack@gmail.com",
|
||||
normalised_to="jack@gmail.com",
|
||||
)
|
||||
|
||||
response = client.get(
|
||||
f"/service/{notification1.service_id}/notifications?"
|
||||
f"to={+447700900855}&template_type={TemplateType.SMS}",
|
||||
headers=[create_admin_authorization_header()],
|
||||
)
|
||||
notifications = json.loads(response.get_data(as_text=True))["notifications"]
|
||||
notification_ids = [notification["id"] for notification in notifications]
|
||||
|
||||
assert response.status_code == 200
|
||||
assert len(notifications) == 3
|
||||
|
||||
assert str(notification1.id) in notification_ids
|
||||
assert str(notification2.id) in notification_ids
|
||||
assert str(notification3.id) in notification_ids
|
||||
assert str(notification4.id) not in notification_ids
|
||||
|
||||
|
||||
@pytest.mark.skip(
|
||||
reason="We can't search on recipient if recipient is not kept in the db"
|
||||
)
|
||||
def test_search_for_notification_by_to_field_returns_next_link_if_more_than_50(
|
||||
client, sample_template
|
||||
):
|
||||
for _ in range(51):
|
||||
create_notification(
|
||||
sample_template,
|
||||
to_field="+447700900855",
|
||||
normalised_to="447700900855",
|
||||
)
|
||||
|
||||
response = client.get(
|
||||
f"/service/{sample_template.service_id}/notifications?"
|
||||
f"to={+447700900855}&template_type={TemplateType.SMS}",
|
||||
headers=[create_admin_authorization_header()],
|
||||
)
|
||||
assert response.status_code == 200
|
||||
response_json = json.loads(response.get_data(as_text=True))
|
||||
|
||||
assert len(response_json["notifications"]) == 50
|
||||
assert "prev" not in response_json["links"]
|
||||
assert "page=2" in response_json["links"]["next"]
|
||||
|
||||
|
||||
@pytest.mark.skip(
|
||||
reason="We can't search on recipient if recipient is not kept in the db"
|
||||
)
|
||||
def test_search_for_notification_by_to_field_returns_no_next_link_if_50_or_less(
|
||||
client, sample_template
|
||||
):
|
||||
for _ in range(50):
|
||||
create_notification(
|
||||
sample_template,
|
||||
to_field="+447700900855",
|
||||
normalised_to="447700900855",
|
||||
)
|
||||
|
||||
response = client.get(
|
||||
f"/service/{sample_template.service_id}/notifications?"
|
||||
f"to={+447700900855}&template_type={TemplateType.SMS}",
|
||||
headers=[create_admin_authorization_header()],
|
||||
)
|
||||
assert response.status_code == 200
|
||||
response_json = json.loads(response.get_data(as_text=True))
|
||||
|
||||
assert len(response_json["notifications"]) == 50
|
||||
assert response_json["links"] == {}
|
||||
|
||||
|
||||
def test_update_service_calls_send_notification_as_service_becomes_live(
|
||||
notify_db_session, client, mocker
|
||||
):
|
||||
@@ -2764,100 +2622,6 @@ def test_update_service_does_not_call_send_notification_when_restricted_not_chan
|
||||
assert not send_notification_mock.called
|
||||
|
||||
|
||||
@pytest.mark.skip(
|
||||
reason="We can't search on recipient if recipient is not kept in the db"
|
||||
)
|
||||
def test_search_for_notification_by_to_field_filters_by_status(client, sample_template):
|
||||
notification1 = create_notification(
|
||||
sample_template,
|
||||
to_field="+447700900855",
|
||||
status=NotificationStatus.DELIVERED,
|
||||
normalised_to="447700900855",
|
||||
)
|
||||
create_notification(
|
||||
sample_template,
|
||||
to_field="+447700900855",
|
||||
status=NotificationStatus.SENDING,
|
||||
normalised_to="447700900855",
|
||||
)
|
||||
|
||||
response = client.get(
|
||||
f"/service/{notification1.service_id}/notifications?to={+447700900855}"
|
||||
f"&status={NotificationStatus.DELIVERED}&template_type={TemplateType.SMS}",
|
||||
headers=[create_admin_authorization_header()],
|
||||
)
|
||||
notifications = json.loads(response.get_data(as_text=True))["notifications"]
|
||||
notification_ids = [notification["id"] for notification in notifications]
|
||||
|
||||
assert response.status_code == 200
|
||||
assert len(notifications) == 1
|
||||
assert str(notification1.id) in notification_ids
|
||||
|
||||
|
||||
@pytest.mark.skip(
|
||||
reason="We can't search on recipient if recipient is not kept in the db"
|
||||
)
|
||||
def test_search_for_notification_by_to_field_filters_by_statuses(
|
||||
client, sample_template
|
||||
):
|
||||
notification1 = create_notification(
|
||||
sample_template,
|
||||
to_field="+447700900855",
|
||||
status=NotificationStatus.DELIVERED,
|
||||
normalised_to="447700900855",
|
||||
)
|
||||
notification2 = create_notification(
|
||||
sample_template,
|
||||
to_field="+447700900855",
|
||||
status=NotificationStatus.SENDING,
|
||||
normalised_to="447700900855",
|
||||
)
|
||||
|
||||
response = client.get(
|
||||
f"/service/{notification1.service_id}/notifications?to={+447700900855}"
|
||||
f"&status={NotificationStatus.DELIVERED}&status={NotificationStatus.SENDING}"
|
||||
f"&template_type={TemplateType.SMS}",
|
||||
headers=[create_admin_authorization_header()],
|
||||
)
|
||||
notifications = json.loads(response.get_data(as_text=True))["notifications"]
|
||||
notification_ids = [notification["id"] for notification in notifications]
|
||||
|
||||
assert response.status_code == 200
|
||||
assert len(notifications) == 2
|
||||
assert str(notification1.id) in notification_ids
|
||||
assert str(notification2.id) in notification_ids
|
||||
|
||||
|
||||
@pytest.mark.skip(
|
||||
reason="We can't search on recipient if recipient is not kept in the db"
|
||||
)
|
||||
def test_search_for_notification_by_to_field_returns_content(
|
||||
client, sample_template_with_placeholders
|
||||
):
|
||||
notification = create_notification(
|
||||
sample_template_with_placeholders,
|
||||
to_field="+447700900855",
|
||||
personalisation={"name": "Foo"},
|
||||
normalised_to="447700900855",
|
||||
)
|
||||
|
||||
response = client.get(
|
||||
f"/service/{sample_template_with_placeholders.service_id}/notifications?"
|
||||
f"to={+447700900855}&template_type={TemplateType.SMS}",
|
||||
headers=[create_admin_authorization_header()],
|
||||
)
|
||||
notifications = json.loads(response.get_data(as_text=True))["notifications"]
|
||||
assert response.status_code == 200
|
||||
assert len(notifications) == 1
|
||||
|
||||
assert notifications[0]["id"] == str(notification.id)
|
||||
assert notifications[0]["to"] == "+447700900855"
|
||||
assert (
|
||||
notifications[0]["template"]["content"]
|
||||
== "Hello (( Name))\nYour thing is due soon"
|
||||
)
|
||||
|
||||
|
||||
def test_send_one_off_notification(sample_service, admin_request, mocker):
|
||||
template = create_template(service=sample_service)
|
||||
mocker.patch("app.service.send_notification.send_notification_to_queue")
|
||||
@@ -2914,61 +2678,6 @@ def test_get_all_notifications_for_service_includes_template_redacted(
|
||||
assert resp["notifications"][1]["template"]["redact_personalisation"] is True
|
||||
|
||||
|
||||
@pytest.mark.skip(
|
||||
reason="We can't search on recipient if recipient is not kept in the db"
|
||||
)
|
||||
def test_search_for_notification_by_to_field_returns_personlisation(
|
||||
client, sample_template_with_placeholders
|
||||
):
|
||||
create_notification(
|
||||
sample_template_with_placeholders,
|
||||
to_field="+447700900855",
|
||||
personalisation={"name": "Foo"},
|
||||
normalised_to="447700900855",
|
||||
)
|
||||
|
||||
response = client.get(
|
||||
f"/service/{sample_template_with_placeholders.service_id}/notifications?"
|
||||
f"to={+447700900855}&template_type={TemplateType.SMS}",
|
||||
headers=[create_admin_authorization_header()],
|
||||
)
|
||||
notifications = json.loads(response.get_data(as_text=True))["notifications"]
|
||||
|
||||
assert response.status_code == 200
|
||||
assert len(notifications) == 1
|
||||
assert "personalisation" in notifications[0].keys()
|
||||
assert notifications[0]["personalisation"]["name"] == "Foo"
|
||||
|
||||
|
||||
@pytest.mark.skip(
|
||||
reason="We can't search on recipient if recipient is not kept in the db"
|
||||
)
|
||||
def test_search_for_notification_by_to_field_returns_notifications_by_type(
|
||||
client, sample_template, sample_email_template
|
||||
):
|
||||
sms_notification = create_notification(
|
||||
sample_template,
|
||||
to_field="+447700900855",
|
||||
normalised_to="447700900855",
|
||||
)
|
||||
create_notification(
|
||||
sample_email_template,
|
||||
to_field="44770@gamil.com",
|
||||
normalised_to="44770@gamil.com",
|
||||
)
|
||||
|
||||
response = client.get(
|
||||
f"/service/{sms_notification.service_id}/notifications?to={'0770'}"
|
||||
f"&template_type={TemplateType.SMS}",
|
||||
headers=[create_admin_authorization_header()],
|
||||
)
|
||||
notifications = json.loads(response.get_data(as_text=True))["notifications"]
|
||||
|
||||
assert response.status_code == 200
|
||||
assert len(notifications) == 1
|
||||
assert notifications[0]["id"] == str(sms_notification.id)
|
||||
|
||||
|
||||
def test_get_email_reply_to_addresses_when_there_are_no_reply_to_email_addresses(
|
||||
client, sample_service
|
||||
):
|
||||
|
||||
Reference in New Issue
Block a user