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

@@ -5,19 +5,21 @@ import pytest
from freezegun import freeze_time
from app import statsd_client
from app.celery.process_sms_client_response_tasks import (
process_sms_client_response,
)
# from app.celery.process_sms_client_response_tasks import (
# process_sms_client_response,
# )
from app.clients import ClientException
from app.models import NOTIFICATION_TECHNICAL_FAILURE
@pytest.mark.skip(reason="Needs updating for TTS: Update with new providers")
def test_process_sms_client_response_raises_error_if_reference_is_not_a_valid_uuid(client):
with pytest.raises(ValueError):
process_sms_client_response(
status='000', provider_reference='something-bad', client_name='sms-client')
@pytest.mark.skip(reason="Needs updating for TTS: Update with new providers")
@pytest.mark.parametrize('client_name', ('Firetext', 'MMG'))
def test_process_sms_response_raises_client_exception_for_unknown_status(
sample_notification,
@@ -35,6 +37,7 @@ def test_process_sms_response_raises_client_exception_for_unknown_status(
assert sample_notification.status == NOTIFICATION_TECHNICAL_FAILURE
@pytest.mark.skip(reason="Needs updating for TTS: Update with new providers")
@pytest.mark.parametrize('status, detailed_status_code, sms_provider, expected_notification_status, reason', [
('0', None, 'Firetext', 'delivered', None),
('1', '101', 'Firetext', 'permanent-failure', 'Unknown Subscriber'),
@@ -63,6 +66,7 @@ def test_process_sms_client_response_updates_notification_status(
assert sample_notification.status == expected_notification_status
@pytest.mark.skip(reason="Needs updating for TTS: Update with new providers")
@pytest.mark.parametrize('detailed_status_code, expected_notification_status, reason', [
('101', 'permanent-failure', 'Unknown Subscriber'),
('102', 'temporary-failure', 'Absent Subscriber'),
@@ -89,6 +93,7 @@ def test_process_sms_client_response_updates_notification_status_when_called_sec
assert sample_notification.status == expected_notification_status
@pytest.mark.skip(reason="Needs updating for TTS: Update with new providers")
@pytest.mark.parametrize('detailed_status_code', ['102', None, '000'])
def test_process_sms_client_response_updates_notification_status_to_pending_with_and_without_failure_code_present(
sample_notification,
@@ -102,6 +107,7 @@ def test_process_sms_client_response_updates_notification_status_to_pending_with
assert sample_notification.status == 'pending'
@pytest.mark.skip(reason="Needs updating for TTS: Update with new providers")
def test_process_sms_client_response_updates_notification_status_when_detailed_status_code_not_recognised(
sample_notification,
mocker,
@@ -116,6 +122,7 @@ def test_process_sms_client_response_updates_notification_status_when_detailed_s
assert sample_notification.status == 'temporary-failure'
@pytest.mark.skip(reason="Needs updating for TTS: Update with new providers")
def test_sms_response_does_not_send_callback_if_notification_is_not_in_the_db(sample_service, mocker):
send_mock = mocker.patch('app.celery.process_sms_client_response_tasks.check_and_queue_callback_task')
reference = str(uuid.uuid4())
@@ -123,6 +130,7 @@ def test_sms_response_does_not_send_callback_if_notification_is_not_in_the_db(sa
send_mock.assert_not_called()
@pytest.mark.skip(reason="Needs updating for TTS: Update with new providers")
@freeze_time('2001-01-01T12:00:00')
def test_process_sms_client_response_records_statsd_metrics(sample_notification, client, mocker):
mocker.patch('app.statsd_client.incr')
@@ -139,6 +147,7 @@ def test_process_sms_client_response_records_statsd_metrics(sample_notification,
)
@pytest.mark.skip(reason="Needs updating for TTS: Update with new providers")
def test_process_sms_updates_billable_units_if_zero(sample_notification):
sample_notification.billable_units = 0
process_sms_client_response('3', str(sample_notification.id), 'MMG')
@@ -146,12 +155,14 @@ def test_process_sms_updates_billable_units_if_zero(sample_notification):
assert sample_notification.billable_units == 1
@pytest.mark.skip(reason="Needs updating for TTS: Update with new providers")
def test_process_sms_response_does_not_send_service_callback_for_pending_notifications(sample_notification, mocker):
send_mock = mocker.patch('app.celery.process_sms_client_response_tasks.check_and_queue_callback_task')
process_sms_client_response('2', str(sample_notification.id), 'Firetext')
send_mock.assert_not_called()
@pytest.mark.skip(reason="Needs updating for TTS: Update with new providers")
def test_outcome_statistics_called_for_successful_callback(sample_notification, mocker):
send_mock = mocker.patch('app.celery.process_sms_client_response_tasks.check_and_queue_callback_task')
reference = str(sample_notification.id)
@@ -160,6 +171,7 @@ def test_outcome_statistics_called_for_successful_callback(sample_notification,
send_mock.assert_called_once_with(sample_notification)
@pytest.mark.skip(reason="Needs updating for TTS: Update with new providers")
def test_process_sms_updates_sent_by_with_client_name_if_not_in_noti(sample_notification):
sample_notification.sent_by = None
process_sms_client_response('3', str(sample_notification.id), 'MMG')