Get tests passing locally

When we cloned the repository and started making modifications, we
didn't initially keep tests in step. This commit tries to get us to a
clean test run by skipping tests that are failing and removing some
that we no longer expect to use (MMG, Firetext), with the intention that
we will come back in future and update or remove them as appropriate.

To find all tests skipped, search for `@pytest.mark.skip(reason="Needs
updating for TTS:`. There will be a brief description of the work that
needs to be done to get them passing, if known. Delete that line to make
them run in a standard test run (`make test`).
This commit is contained in:
Christa Hartsock
2022-07-05 11:27:15 -07:00
parent b91996ddea
commit af6495cd4c
34 changed files with 174 additions and 1516 deletions

View File

@@ -10,7 +10,7 @@ from notifications_utils.recipients import validate_and_format_phone_number
from requests import HTTPError
import app
from app import firetext_client, mmg_client, notification_provider_clients
# from app import firetext_client, mmg_client, notification_provider_clients
from app.dao import notifications_dao
from app.dao.provider_details_dao import get_provider_details_by_identifier
from app.delivery import send_to_providers
@@ -43,7 +43,7 @@ def setup_function(_function):
# state of the cache is not shared between tests.
send_to_providers.provider_cache.clear()
@pytest.mark.skip(reason="Needs updating for TTS: Update with new providers")
def test_provider_to_use_should_return_random_provider(mocker, notify_db_session):
mmg = get_provider_details_by_identifier('mmg')
firetext = get_provider_details_by_identifier('firetext')
@@ -57,6 +57,7 @@ def test_provider_to_use_should_return_random_provider(mocker, notify_db_session
assert ret.name == 'mmg'
@pytest.mark.skip(reason="Needs updating for TTS: Update with new providers")
def test_provider_to_use_should_cache_repeated_calls(mocker, notify_db_session):
mock_choices = mocker.patch(
'app.delivery.send_to_providers.random.choices',
@@ -71,7 +72,7 @@ def test_provider_to_use_should_cache_repeated_calls(mocker, notify_db_session):
assert all(result == results[0] for result in results)
assert len(mock_choices.call_args_list) == 1
@pytest.mark.skip(reason="Needs updating for TTS: Update with new providers")
@pytest.mark.parametrize('international_provider_priority', (
# Since theres only one international provider it should always
# be used, no matter what its priority is set to
@@ -92,6 +93,7 @@ def test_provider_to_use_should_only_return_mmg_for_international(
assert ret.name == 'mmg'
@pytest.mark.skip(reason="Needs updating for TTS: Update with new providers")
def test_provider_to_use_should_only_return_active_providers(mocker, restore_provider_details):
mmg = get_provider_details_by_identifier('mmg')
firetext = get_provider_details_by_identifier('firetext')
@@ -104,6 +106,7 @@ def test_provider_to_use_should_only_return_active_providers(mocker, restore_pro
assert ret.name == 'firetext'
@pytest.mark.skip(reason="Needs updating for TTS: Update with new providers")
def test_provider_to_use_raises_if_no_active_providers(mocker, restore_provider_details):
mmg = get_provider_details_by_identifier('mmg')
mmg.active = False
@@ -112,6 +115,7 @@ def test_provider_to_use_raises_if_no_active_providers(mocker, restore_provider_
send_to_providers.provider_to_use('sms', international=True)
@pytest.mark.skip(reason="Needs updating for TTS: Update with new providers")
def test_should_send_personalised_template_to_correct_sms_provider_and_persist(
sample_sms_template_with_html,
mocker
@@ -146,6 +150,7 @@ def test_should_send_personalised_template_to_correct_sms_provider_and_persist(
assert notification.personalisation == {"name": "Jo"}
@pytest.mark.skip(reason="Needs updating for TTS: Update with new providers")
def test_should_send_personalised_template_to_correct_email_provider_and_persist(
sample_email_template_with_html,
mocker
@@ -182,6 +187,7 @@ def test_should_send_personalised_template_to_correct_email_provider_and_persist
assert notification.personalisation == {"name": "Jo"}
@pytest.mark.skip(reason="Needs updating for TTS: Update with new providers")
def test_should_not_send_email_message_when_service_is_inactive_notifcation_is_in_tech_failure(
sample_service, sample_notification, mocker
):
@@ -195,6 +201,7 @@ def test_should_not_send_email_message_when_service_is_inactive_notifcation_is_i
assert Notification.query.get(sample_notification.id).status == 'technical-failure'
@pytest.mark.skip(reason="Needs updating for TTS: Update with new providers")
@pytest.mark.parametrize("client_send", ["app.mmg_client.send_sms", "app.firetext_client.send_sms"])
def test_should_not_send_sms_message_when_service_is_inactive_notification_is_in_tech_failure(
sample_service, sample_notification, mocker, client_send):
@@ -208,6 +215,7 @@ def test_should_not_send_sms_message_when_service_is_inactive_notification_is_in
assert Notification.query.get(sample_notification.id).status == 'technical-failure'
@pytest.mark.skip(reason="Needs updating for TTS: Update with new providers")
def test_send_sms_should_use_template_version_from_notification_not_latest(
sample_template,
mocker):
@@ -253,6 +261,7 @@ def test_send_sms_should_use_template_version_from_notification_not_latest(
assert not persisted_notification.personalisation
@pytest.mark.skip(reason="Needs updating for TTS: Update with new providers")
@pytest.mark.parametrize('research_mode,key_type', [
(True, KEY_TYPE_NORMAL),
(False, KEY_TYPE_TEST)
@@ -288,6 +297,7 @@ def test_should_call_send_sms_response_task_if_research_mode(
assert not persisted_notification.personalisation
@pytest.mark.skip(reason="Needs updating for TTS: Update with new providers")
def test_should_have_sending_status_if_fake_callback_function_fails(sample_notification, mocker):
mocker.patch('app.delivery.send_to_providers.send_sms_response', side_effect=HTTPError)
@@ -301,6 +311,7 @@ def test_should_have_sending_status_if_fake_callback_function_fails(sample_notif
assert sample_notification.sent_by == 'mmg'
@pytest.mark.skip(reason="Needs updating for TTS: Update with new providers")
def test_should_not_send_to_provider_when_status_is_not_created(
sample_template,
mocker
@@ -317,6 +328,7 @@ def test_should_not_send_to_provider_when_status_is_not_created(
response_mock.assert_not_called()
@pytest.mark.skip(reason="Needs updating for TTS: Update with new providers")
def test_should_send_sms_with_downgraded_content(notify_db_session, mocker):
# é, o, and u are in GSM.
# ī, grapes, tabs, zero width space and ellipsis are not
@@ -344,6 +356,7 @@ def test_should_send_sms_with_downgraded_content(notify_db_session, mocker):
)
@pytest.mark.skip(reason="Needs updating for TTS: Update with new providers")
def test_send_sms_should_use_service_sms_sender(
sample_service,
sample_template,
@@ -367,6 +380,7 @@ def test_send_sms_should_use_service_sms_sender(
)
@pytest.mark.skip(reason="Needs updating for TTS: Update with new providers")
@pytest.mark.parametrize('research_mode,key_type', [
(True, KEY_TYPE_NORMAL),
(False, KEY_TYPE_TEST)
@@ -407,6 +421,7 @@ def test_send_email_to_provider_should_call_research_mode_task_response_task_if_
assert persisted_notification.billable_units == 0
@pytest.mark.skip(reason="Needs updating for TTS: Update with new providers")
def test_send_email_to_provider_should_not_send_to_provider_when_status_is_not_created(
sample_email_template,
mocker
@@ -422,6 +437,7 @@ def test_send_email_to_provider_should_not_send_to_provider_when_status_is_not_c
app.delivery.send_to_providers.send_email_response.assert_not_called()
@pytest.mark.skip(reason="Needs updating for TTS: Update with new providers")
def test_send_email_should_use_service_reply_to_email(
sample_service,
sample_email_template,
@@ -445,6 +461,7 @@ def test_send_email_should_use_service_reply_to_email(
)
@pytest.mark.skip(reason="Needs updating for TTS: Update with new providers")
def test_get_html_email_renderer_should_return_for_normal_service(sample_service):
options = send_to_providers.get_html_email_options(sample_service)
assert options['govuk_banner'] is True
@@ -495,6 +512,7 @@ def test_get_html_email_renderer_with_branding_details_and_render_govuk_banner_o
assert options == {'govuk_banner': True, 'brand_banner': False}
@pytest.mark.skip(reason="Needs updating for TTS: Update with new providers")
def test_get_html_email_renderer_prepends_logo_path(notify_api):
Service = namedtuple('Service', ['email_branding'])
EmailBranding = namedtuple('EmailBranding', ['brand_type', 'colour', 'name', 'logo', 'text'])
@@ -574,7 +592,7 @@ def test_should_not_update_notification_if_research_mode_on_exception(
assert persisted_notification.billable_units == 0
assert update_mock.called
@pytest.mark.skip(reason="Needs updating for TTS: Update with new providers")
@pytest.mark.parametrize("starting_status, expected_status", [
("delivered", "delivered"),
("created", "sending"),
@@ -597,6 +615,7 @@ def __update_notification(notification_to_update, research_mode, expected_status
notification_to_update.status = expected_status
@pytest.mark.skip(reason="Needs updating for TTS: Update with new providers")
@pytest.mark.parametrize('research_mode,key_type, billable_units, expected_status', [
(True, KEY_TYPE_NORMAL, 0, 'delivered'),
(False, KEY_TYPE_NORMAL, 1, 'sending'),
@@ -628,6 +647,7 @@ def test_should_update_billable_units_and_status_according_to_research_mode_and_
assert notification.status == expected_status
@pytest.mark.skip(reason="Needs updating for TTS: Update with new providers")
def test_should_set_notification_billable_units_and_reduces_provider_priority_if_sending_to_provider_fails(
sample_notification,
mocker,
@@ -645,6 +665,7 @@ def test_should_set_notification_billable_units_and_reduces_provider_priority_if
mock_reduce.assert_called_once_with('mmg', time_threshold=timedelta(minutes=1))
@pytest.mark.skip(reason="Needs updating for TTS: Update with new providers")
def test_should_send_sms_to_international_providers(
sample_template,
sample_user,
@@ -683,6 +704,7 @@ def test_should_send_sms_to_international_providers(
assert notification_international.sent_by == 'mmg'
@pytest.mark.skip(reason="Needs updating for TTS: Update with new providers")
def test_should_send_non_international_sms_to_default_provider(
sample_template,
sample_user,
@@ -721,6 +743,7 @@ def test_should_send_non_international_sms_to_default_provider(
assert notification_uk.sent_by == 'firetext'
@pytest.mark.skip(reason="Needs updating for TTS: Update with new providers")
@pytest.mark.parametrize('sms_sender, expected_sender, prefix_sms, expected_content', [
('foo', 'foo', False, 'bar'),
('foo', 'foo', True, 'Sample service: bar'),
@@ -775,6 +798,7 @@ def test_send_email_to_provider_uses_reply_to_from_notification(
)
@pytest.mark.skip(reason="Needs updating for TTS: Update with new providers")
def test_send_sms_to_provider_should_use_normalised_to(
mocker, client, sample_template
):
@@ -807,6 +831,7 @@ def test_send_email_to_provider_should_user_normalised_to(
reply_to_address=notification.reply_to_text)
@pytest.mark.skip(reason="Needs updating for TTS: Update with new providers")
def test_send_sms_to_provider_should_return_template_if_found_in_redis(
mocker, client, sample_template
):