Skip to content

Commit

Permalink
#1635 Remove Unused Pytest Fixtures (#1674)
Browse files Browse the repository at this point in the history
Co-authored-by: Mackenzie Halliday <[email protected]>
Co-authored-by: Michael Wellman <[email protected]>
Co-authored-by: David Kalbfleisch <[email protected]>
  • Loading branch information
4 people authored Mar 7, 2024
1 parent fc92d17 commit 037c0a7
Show file tree
Hide file tree
Showing 15 changed files with 241 additions and 1,025 deletions.
5 changes: 2 additions & 3 deletions tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ The docker-compose command used to run the full test suite sets environment vari

1. Stop all running containers associated with Notification-api.
2. Start the Postgres (ci_db_1) container, and any other containers required by the functionality under test: `docker start ci-db-1`. All migrations should already be applied.
3. Start a test container shell by running `docker run --rm -it -v "$(pwd):/app" --env-file tests/env_vars --name ci-test ci-test bash`.
4. Add the test container started in the previous step to the default network: `docker network connect ci_default ci-test`.
5. In the test container shell, run `pytest -h` to see the syntax for running tests. Without flags, you can run `pytest [file or directory]...`.
3. Start a test container shell by running `docker run --rm -it -v "$(pwd):/app" --env-file tests/env_vars --name ci-test --network ci_default ci-test bash`.
4. In the test container shell, run `pytest -h` to see the syntax for running tests. Without flags, you can run `pytest [file or directory]...`.

## Running Individual Tests

Expand Down
19 changes: 0 additions & 19 deletions tests/app/celery/test_process_delivery_status_result_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,6 @@
from app.models import Notification


@pytest.fixture
def sample_translate_return_value():
return {
'payload': 'eyJhcmdzIjogW3siTWVzc2FnZSI6IHsiYm9keSI6ICJSYXdEbHJEb25lRGF0ZT0yMzAzMDkyMDI',
'reference': 'MessageSID',
'record_status': 'sent',
}


@pytest.fixture
def sample_delivery_status_result_message():
return {
Expand Down Expand Up @@ -53,16 +44,6 @@ def sample_sqs_message_with_provider():
}


@pytest.fixture()
def sample_sqs_message_with_twilio_provider():
return {
'body': 'UmF3RGxyRG9uZURhdGU9MjMwMzIyMjMzOCZTbXNTaWQ9U014eHgmU21zU3RhdHVzPWRlbGl2ZXJlZCZNZXNzYWdlU3RhdHV'
'zPWRlbGl2ZXJlZCZUbz0lMkIxMTExMTExMTExMSZNZXNzYWdlU2lkPVNNeXl5JkFjY291bnRTaWQ9QUN6enomRnJvbT0lMkIx'
'MjIyMzMzNDQ0NCZBcGlWZXJzaW9uPTIwMTAtMDQtMDE=',
'provider': 'twilio',
}


@pytest.fixture()
def sample_sqs_message_without_provider():
return {
Expand Down
4 changes: 2 additions & 2 deletions tests/app/celery/test_service_callback_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ def _set_up_data_for_complaint(callback_api, complaint, notification):

class TestSendInboundSmsToService:
def test_post_https_request_to_service(
self, mocker, sample_inbound_sms, sample_service, sample_service_callback, sample_sms_sender_v2
self, mocker, sample_inbound_sms, sample_service, sample_service_callback, sample_sms_sender
):
service = sample_service()
inbound_api = sample_service_callback( # nosec
Expand All @@ -408,7 +408,7 @@ def test_post_https_request_to_service(
provider_date=datetime(2017, 6, 20),
content='Here is some content',
)
sms_sender = sample_sms_sender_v2(service_id=service.id, sms_sender='0751421')
sms_sender = sample_sms_sender(service_id=service.id, sms_sender='0751421')

expected_data = {
'id': str(inbound_sms.id),
Expand Down
19 changes: 10 additions & 9 deletions tests/app/celery/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,18 +404,19 @@ def test_process_row_when_sender_id_is_provided(mocker, fake_uuid):


def test_should_send_template_to_correct_sms_task_and_persist(
notify_db_session, sample_template_with_placeholders, mocker
notify_db_session, sample_service, sample_template, mocker
):
notification = _notification_json(
sample_template_with_placeholders, to='+1 650 253 2222', personalisation={'name': 'Jo'}
)
service = sample_service()
template = sample_template(service=service)

notification = _notification_json(template, to='+1 650 253 2222', personalisation={'name': 'Jo'})

mocked_deliver_sms = mocker.patch('app.celery.provider_tasks.deliver_sms.apply_async')

notification_id = uuid4()

save_sms(
sample_template_with_placeholders.service_id,
template.service_id,
notification_id,
encryption.encrypt(notification),
)
Expand All @@ -424,8 +425,8 @@ def test_should_send_template_to_correct_sms_task_and_persist(

try:
assert persisted_notification.to == '+1 650 253 2222'
assert persisted_notification.template_id == sample_template_with_placeholders.id
assert persisted_notification.template_version == sample_template_with_placeholders.version
assert persisted_notification.template_id == template.id
assert persisted_notification.template_version == template.version
assert persisted_notification.status == 'created'
assert persisted_notification.created_at <= datetime.utcnow()
assert not persisted_notification.sent_at
Expand Down Expand Up @@ -1106,13 +1107,13 @@ def test_save_sms_uses_sms_sender_reply_to_text(mocker, notify_db_session, sampl


def test_save_sms_uses_non_default_sms_sender_reply_to_text_if_provided(
mocker, notify_db_session, sample_service, sample_template, sample_sms_sender_v2
mocker, notify_db_session, sample_service, sample_template, sample_sms_sender
):
mock_feature_flag(mocker, FeatureFlag.SMS_SENDER_RATE_LIMIT_ENABLED, 'True')
service = sample_service(sms_sender='07123123123')
template = sample_template(service=service)
# new_sender = service_sms_sender_dao.dao_add_sms_sender_for_service(service.id, 'new-sender', False)
new_sender = sample_sms_sender_v2(service.id, sms_sender='new-sender', is_default=False)
new_sender = sample_sms_sender(service.id, sms_sender='new-sender', is_default=False)
sms_sender = mocker.Mock()
sms_sender.rate_limit = 1
sms_sender.sms_sender = 'new-sender'
Expand Down
Loading

0 comments on commit 037c0a7

Please sign in to comment.