diff --git a/tests/app/dao/test_templates_dao.py b/tests/app/dao/test_templates_dao.py index 05df996be..01f4ddaa1 100644 --- a/tests/app/dao/test_templates_dao.py +++ b/tests/app/dao/test_templates_dao.py @@ -221,7 +221,7 @@ def test_redact_template(sample_template): assert redacted.updated_by_id == sample_template.created_by_id -def test_get_all_templates_for_service(notify_db_session, service_factory): +def test_get_all_templates_for_service(service_factory): service_1 = service_factory.get('service 1', email_from='service.1') service_2 = service_factory.get('service 2', email_from='service.2') @@ -253,7 +253,7 @@ def test_get_all_templates_for_service(notify_db_session, service_factory): assert len(dao_get_all_templates_for_service(service_2.id)) == 2 -def test_get_all_templates_for_service_is_alphabetised(notify_db_session, sample_service): +def test_get_all_templates_for_service_is_alphabetised(sample_service): create_template( template_name='Sample Template 1', template_type="sms", @@ -289,7 +289,7 @@ def test_get_all_returns_empty_list_if_no_templates(sample_service): assert len(dao_get_all_templates_for_service(sample_service.id)) == 0 -def test_get_all_templates_ignores_archived_templates(notify_db_session, sample_service): +def test_get_all_templates_ignores_archived_templates(sample_service): normal_template = create_template( template_name='Normal Template', service=sample_service, @@ -309,7 +309,7 @@ def test_get_all_templates_ignores_archived_templates(notify_db_session, sample_ assert templates[0] == normal_template -def test_get_all_templates_ignores_hidden_templates(notify_db_session, sample_service): +def test_get_all_templates_ignores_hidden_templates(sample_service): normal_template = create_template( template_name='Normal Template', service=sample_service, @@ -328,7 +328,7 @@ def test_get_all_templates_ignores_hidden_templates(notify_db_session, sample_se assert templates[0] == normal_template -def test_get_template_by_id_and_service(notify_db_session, sample_service): +def test_get_template_by_id_and_service(sample_service): sample_template = create_template( template_name='Test Template', service=sample_service) @@ -341,7 +341,7 @@ def test_get_template_by_id_and_service(notify_db_session, sample_service): assert not template.redact_personalisation -def test_get_template_by_id_and_service_returns_none_for_hidden_templates(notify_db_session, sample_service): +def test_get_template_by_id_and_service_returns_none_for_hidden_templates(sample_service): sample_template = create_template( template_name='Test Template', hidden=True, @@ -355,7 +355,7 @@ def test_get_template_by_id_and_service_returns_none_for_hidden_templates(notify ) -def test_get_template_version_returns_none_for_hidden_templates(notify_db_session, sample_service): +def test_get_template_version_returns_none_for_hidden_templates(sample_service): sample_template = create_template( template_name='Test Template', hidden=True, @@ -477,7 +477,7 @@ def test_get_template_versions(sample_template): assert len(v) == 2 -def test_get_template_versions_is_empty_for_hidden_templates(notify_db, notify_db_session, sample_service): +def test_get_template_versions_is_empty_for_hidden_templates(sample_service): sample_template = create_template( template_name='Test Template', hidden=True, diff --git a/tests/app/test_model.py b/tests/app/test_model.py index 0c7b78bce..bb2961a6b 100644 --- a/tests/app/test_model.py +++ b/tests/app/test_model.py @@ -176,15 +176,11 @@ def test_notification_subject_is_none_for_sms(): assert Notification(notification_type=SMS_TYPE).subject is None -def test_notification_subject_fills_in_placeholders_for_email(sample_email_template_with_placeholders): - noti = create_notification(sample_email_template_with_placeholders, personalisation={'name': 'hello'}) - assert noti.subject == 'hello' - - -def test_notification_subject_fills_in_placeholders_for_letter(sample_service): - template = create_template(service=sample_service, template_type='email', subject='((name))') - noti = create_notification(template=template, personalisation={'name': 'hello'}) - assert noti.subject == 'hello' +@pytest.mark.parametrize('template_type', ['email', 'letter']) +def test_notification_subject_fills_in_placeholders(sample_service, template_type): + template = create_template(service=sample_service, template_type=template_type, subject='((name))') + notification = create_notification(template=template, personalisation={'name': 'hello'}) + assert notification.subject == 'hello' def test_letter_notification_serializes_with_address(client, sample_letter_notification): diff --git a/tests/app/v2/notifications/test_post_notifications.py b/tests/app/v2/notifications/test_post_notifications.py index df3945b9a..9c4440619 100644 --- a/tests/app/v2/notifications/test_post_notifications.py +++ b/tests/app/v2/notifications/test_post_notifications.py @@ -609,8 +609,9 @@ def test_post_sms_should_persist_supplied_sms_number(client, sample_template_wit [("sms", "phone_number", "07700 900 855"), ("email", "email_address", "sample@email.com")]) @freeze_time("2017-05-14 14:00:00") -def test_post_notification_with_scheduled_for(client, notify_db, notify_db_session, - notification_type, key_send_to, send_to): +def test_post_notification_with_scheduled_for( + client, notify_db_session, notification_type, key_send_to, send_to +): service = create_service(service_name=str(uuid.uuid4()), service_permissions=[EMAIL_TYPE, SMS_TYPE, SCHEDULE_NOTIFICATIONS]) template = create_template(service=service, template_type=notification_type) @@ -863,7 +864,7 @@ def test_post_notification_without_document_upload_permission(client, notify_db_ assert response.status_code == 400, response.get_data(as_text=True) -def test_post_notification_returns_400_when_get_json_throws_exception(client, sample_email_template, rmock, mocker): +def test_post_notification_returns_400_when_get_json_throws_exception(client, sample_email_template): auth_header = create_authorization_header(service_id=sample_email_template.service_id) response = client.post( path="v2/notifications/email",