mirror of
https://github.com/GSA/notifications-api.git
synced 2026-07-30 19:28:50 -04:00
Stop calling fixtures as functions in the tests
This commit is contained in:
@@ -18,7 +18,6 @@ from tests.app.db import (
|
||||
ses_complaint_callback,
|
||||
create_service_callback_api,
|
||||
)
|
||||
from tests.app.conftest import sample_notification as create_sample_notification
|
||||
|
||||
|
||||
def test_process_ses_results(sample_email_template):
|
||||
@@ -60,7 +59,6 @@ def test_remove_email_from_bounce():
|
||||
|
||||
def test_ses_callback_should_update_notification_status(
|
||||
client,
|
||||
notify_db,
|
||||
notify_db_session,
|
||||
sample_email_template,
|
||||
mocker):
|
||||
@@ -70,13 +68,10 @@ def test_ses_callback_should_update_notification_status(
|
||||
send_mock = mocker.patch(
|
||||
'app.celery.service_callback_tasks.send_delivery_status_to_service.apply_async'
|
||||
)
|
||||
notification = create_sample_notification(
|
||||
notify_db,
|
||||
notify_db_session,
|
||||
notification = create_notification(
|
||||
template=sample_email_template,
|
||||
reference='ref',
|
||||
status='sending',
|
||||
sent_at=datetime.utcnow()
|
||||
reference='ref',
|
||||
)
|
||||
callback_api = create_service_callback_api(service=sample_email_template.service,
|
||||
url="https://original_url.com")
|
||||
@@ -137,7 +132,6 @@ def test_ses_callback_should_not_retry_if_notification_is_old(client, notify_db,
|
||||
|
||||
def test_ses_callback_does_not_call_send_delivery_status_if_no_db_entry(
|
||||
client,
|
||||
notify_db,
|
||||
notify_db_session,
|
||||
sample_email_template,
|
||||
mocker):
|
||||
@@ -146,13 +140,10 @@ def test_ses_callback_does_not_call_send_delivery_status_if_no_db_entry(
|
||||
send_mock = mocker.patch(
|
||||
'app.celery.service_callback_tasks.send_delivery_status_to_service.apply_async'
|
||||
)
|
||||
notification = create_sample_notification(
|
||||
notify_db,
|
||||
notify_db_session,
|
||||
notification = create_notification(
|
||||
template=sample_email_template,
|
||||
reference='ref',
|
||||
status='sending',
|
||||
sent_at=datetime.utcnow()
|
||||
reference='ref',
|
||||
)
|
||||
|
||||
assert get_notification_by_id(notification.id).status == 'sending'
|
||||
@@ -165,7 +156,6 @@ def test_ses_callback_does_not_call_send_delivery_status_if_no_db_entry(
|
||||
|
||||
def test_ses_callback_should_update_multiple_notification_status_sent(
|
||||
client,
|
||||
notify_db,
|
||||
notify_db_session,
|
||||
sample_email_template,
|
||||
mocker):
|
||||
@@ -173,29 +163,21 @@ def test_ses_callback_should_update_multiple_notification_status_sent(
|
||||
send_mock = mocker.patch(
|
||||
'app.celery.service_callback_tasks.send_delivery_status_to_service.apply_async'
|
||||
)
|
||||
create_sample_notification(
|
||||
notify_db,
|
||||
notify_db_session,
|
||||
create_notification(
|
||||
template=sample_email_template,
|
||||
status='sending',
|
||||
reference='ref1',
|
||||
sent_at=datetime.utcnow(),
|
||||
status='sending')
|
||||
|
||||
create_sample_notification(
|
||||
notify_db,
|
||||
notify_db_session,
|
||||
)
|
||||
create_notification(
|
||||
template=sample_email_template,
|
||||
status='sending',
|
||||
reference='ref2',
|
||||
sent_at=datetime.utcnow(),
|
||||
status='sending')
|
||||
|
||||
create_sample_notification(
|
||||
notify_db,
|
||||
notify_db_session,
|
||||
)
|
||||
create_notification(
|
||||
template=sample_email_template,
|
||||
status='sending',
|
||||
reference='ref3',
|
||||
sent_at=datetime.utcnow(),
|
||||
status='sending')
|
||||
)
|
||||
create_service_callback_api(service=sample_email_template.service, url="https://original_url.com")
|
||||
assert process_ses_results(ses_notification_callback(reference='ref1'))
|
||||
assert process_ses_results(ses_notification_callback(reference='ref2'))
|
||||
@@ -204,20 +186,16 @@ def test_ses_callback_should_update_multiple_notification_status_sent(
|
||||
|
||||
|
||||
def test_ses_callback_should_set_status_to_temporary_failure(client,
|
||||
notify_db,
|
||||
notify_db_session,
|
||||
sample_email_template,
|
||||
mocker):
|
||||
send_mock = mocker.patch(
|
||||
'app.celery.service_callback_tasks.send_delivery_status_to_service.apply_async'
|
||||
)
|
||||
notification = create_sample_notification(
|
||||
notify_db,
|
||||
notify_db_session,
|
||||
notification = create_notification(
|
||||
template=sample_email_template,
|
||||
reference='ref',
|
||||
status='sending',
|
||||
sent_at=datetime.utcnow()
|
||||
reference='ref',
|
||||
)
|
||||
create_service_callback_api(service=notification.service, url="https://original_url.com")
|
||||
assert get_notification_by_id(notification.id).status == 'sending'
|
||||
@@ -227,20 +205,16 @@ def test_ses_callback_should_set_status_to_temporary_failure(client,
|
||||
|
||||
|
||||
def test_ses_callback_should_set_status_to_permanent_failure(client,
|
||||
notify_db,
|
||||
notify_db_session,
|
||||
sample_email_template,
|
||||
mocker):
|
||||
send_mock = mocker.patch(
|
||||
'app.celery.service_callback_tasks.send_delivery_status_to_service.apply_async'
|
||||
)
|
||||
notification = create_sample_notification(
|
||||
notify_db,
|
||||
notify_db_session,
|
||||
notification = create_notification(
|
||||
template=sample_email_template,
|
||||
reference='ref',
|
||||
status='sending',
|
||||
sent_at=datetime.utcnow()
|
||||
reference='ref',
|
||||
)
|
||||
create_service_callback_api(service=sample_email_template.service, url="https://original_url.com")
|
||||
|
||||
|
||||
@@ -38,7 +38,6 @@ from tests.app.db import (
|
||||
create_template,
|
||||
create_job,
|
||||
)
|
||||
from tests.app.conftest import sample_job as create_sample_job
|
||||
|
||||
|
||||
def _create_slow_delivery_notification(template, provider='mmg'):
|
||||
@@ -74,11 +73,11 @@ def test_should_call_delete_invotations_on_delete_invitations_task(notify_api, m
|
||||
assert scheduled_tasks.delete_invitations_created_more_than_two_days_ago.call_count == 1
|
||||
|
||||
|
||||
def test_should_update_scheduled_jobs_and_put_on_queue(notify_db, notify_db_session, mocker):
|
||||
def test_should_update_scheduled_jobs_and_put_on_queue(mocker, sample_template):
|
||||
mocked = mocker.patch('app.celery.tasks.process_job.apply_async')
|
||||
|
||||
one_minute_in_the_past = datetime.utcnow() - timedelta(minutes=1)
|
||||
job = create_sample_job(notify_db, notify_db_session, scheduled_for=one_minute_in_the_past, job_status='scheduled')
|
||||
job = create_job(sample_template, job_status='scheduled', scheduled_for=one_minute_in_the_past)
|
||||
|
||||
run_scheduled_jobs()
|
||||
|
||||
@@ -87,30 +86,15 @@ def test_should_update_scheduled_jobs_and_put_on_queue(notify_db, notify_db_sess
|
||||
mocked.assert_called_with([str(job.id)], queue="job-tasks")
|
||||
|
||||
|
||||
def test_should_update_all_scheduled_jobs_and_put_on_queue(notify_db, notify_db_session, mocker):
|
||||
def test_should_update_all_scheduled_jobs_and_put_on_queue(sample_template, mocker):
|
||||
mocked = mocker.patch('app.celery.tasks.process_job.apply_async')
|
||||
|
||||
one_minute_in_the_past = datetime.utcnow() - timedelta(minutes=1)
|
||||
ten_minutes_in_the_past = datetime.utcnow() - timedelta(minutes=10)
|
||||
twenty_minutes_in_the_past = datetime.utcnow() - timedelta(minutes=20)
|
||||
job_1 = create_sample_job(
|
||||
notify_db,
|
||||
notify_db_session,
|
||||
scheduled_for=one_minute_in_the_past,
|
||||
job_status='scheduled'
|
||||
)
|
||||
job_2 = create_sample_job(
|
||||
notify_db,
|
||||
notify_db_session,
|
||||
scheduled_for=ten_minutes_in_the_past,
|
||||
job_status='scheduled'
|
||||
)
|
||||
job_3 = create_sample_job(
|
||||
notify_db,
|
||||
notify_db_session,
|
||||
scheduled_for=twenty_minutes_in_the_past,
|
||||
job_status='scheduled'
|
||||
)
|
||||
job_1 = create_job(sample_template, job_status='scheduled', scheduled_for=one_minute_in_the_past)
|
||||
job_2 = create_job(sample_template, job_status='scheduled', scheduled_for=ten_minutes_in_the_past)
|
||||
job_3 = create_job(sample_template, job_status='scheduled', scheduled_for=twenty_minutes_in_the_past)
|
||||
|
||||
run_scheduled_jobs()
|
||||
|
||||
|
||||
@@ -411,9 +411,8 @@ def test_save_notification_and_increment_job(sample_template, sample_job, mmg_pr
|
||||
|
||||
|
||||
def test_save_notification_and_increment_correct_job(notify_db, notify_db_session, sample_template, mmg_provider):
|
||||
from tests.app.conftest import sample_job
|
||||
job_1 = sample_job(notify_db, notify_db_session, sample_template.service)
|
||||
job_2 = sample_job(notify_db, notify_db_session, sample_template.service)
|
||||
job_1 = create_job(sample_template)
|
||||
job_2 = create_job(sample_template)
|
||||
|
||||
assert Notification.query.count() == 0
|
||||
data = _notification_json(sample_template, job_id=job_1.id)
|
||||
|
||||
@@ -15,6 +15,7 @@ from app.dao.invited_user_dao import (
|
||||
get_invited_user_by_id,
|
||||
delete_invitations_created_more_than_two_days_ago
|
||||
)
|
||||
from tests.app.db import create_invited_user
|
||||
|
||||
|
||||
def test_create_invited_user(notify_db, notify_db_session, sample_service):
|
||||
@@ -84,15 +85,11 @@ def test_get_unknown_invited_user_returns_none(notify_db, notify_db_session, sam
|
||||
|
||||
|
||||
def test_get_invited_users_for_service(notify_db, notify_db_session, sample_service):
|
||||
from tests.app.conftest import sample_invited_user
|
||||
invites = []
|
||||
for i in range(0, 5):
|
||||
email = 'invited_user_{}@service.gov.uk'.format(i)
|
||||
|
||||
invited_user = sample_invited_user(notify_db,
|
||||
notify_db_session,
|
||||
sample_service,
|
||||
email)
|
||||
invited_user = create_invited_user(sample_service, to_email_address=email)
|
||||
invites.append(invited_user)
|
||||
|
||||
all_from_db = get_invited_users_for_service(sample_service.id)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from app.dao.permissions_dao import permission_dao
|
||||
from tests.app.conftest import sample_service as create_service
|
||||
from tests.app.db import create_service
|
||||
|
||||
|
||||
def test_get_permissions_by_user_id_returns_all_permissions(sample_service):
|
||||
@@ -15,11 +15,10 @@ def test_get_permissions_by_user_id_returns_all_permissions(sample_service):
|
||||
"view_activity"]) == sorted([i.permission for i in permissions])
|
||||
|
||||
|
||||
def test_get_permissions_by_user_id_returns_only_active_service(notify_db, notify_db_session, sample_user):
|
||||
active_service = create_service(notify_db, notify_db_session, service_name="Active service", user=sample_user)
|
||||
inactive_service = create_service(notify_db, notify_db_session, service_name="Inactive service",
|
||||
user=sample_user)
|
||||
inactive_service.active = False
|
||||
def test_get_permissions_by_user_id_returns_only_active_service(sample_user):
|
||||
active_service = create_service(user=sample_user, service_name="Active service")
|
||||
inactive_service = create_service(user=sample_user, service_name="Inactive service", active=False)
|
||||
|
||||
permissions = permission_dao.get_permissions_by_user_id(user_id=sample_user.id)
|
||||
assert len(permissions) == 8
|
||||
assert active_service in [i.service for i in permissions]
|
||||
|
||||
@@ -10,8 +10,7 @@ from app.dao.service_whitelist_dao import (
|
||||
dao_add_and_commit_whitelisted_contacts,
|
||||
dao_remove_service_whitelist
|
||||
)
|
||||
|
||||
from tests.app.conftest import sample_service as create_service
|
||||
from tests.app.db import create_service
|
||||
|
||||
|
||||
def test_fetch_service_whitelist_gets_whitelists(sample_service_whitelist):
|
||||
@@ -35,8 +34,8 @@ def test_add_and_commit_whitelisted_contacts_saves_data(sample_service):
|
||||
|
||||
|
||||
def test_remove_service_whitelist_only_removes_for_my_service(notify_db, notify_db_session):
|
||||
service_1 = create_service(notify_db, notify_db_session, service_name="service 1")
|
||||
service_2 = create_service(notify_db, notify_db_session, service_name="service 2")
|
||||
service_1 = create_service(service_name="service 1")
|
||||
service_2 = create_service(service_name="service 2")
|
||||
dao_add_and_commit_whitelisted_contacts([
|
||||
ServiceWhitelist.from_string(service_1.id, EMAIL_TYPE, 'service1@example.com'),
|
||||
ServiceWhitelist.from_string(service_2.id, EMAIL_TYPE, 'service2@example.com')
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
from datetime import datetime
|
||||
|
||||
import pytest
|
||||
from flask import json
|
||||
from sqlalchemy.exc import SQLAlchemyError
|
||||
@@ -8,7 +6,6 @@ from app.dao.notifications_dao import get_notification_by_id
|
||||
from app.models import Complaint
|
||||
from app.notifications.notifications_ses_callback import handle_complaint
|
||||
|
||||
from tests.app.conftest import sample_notification as create_sample_notification
|
||||
from tests.app.db import (
|
||||
create_notification, ses_complaint_callback_malformed_message_id,
|
||||
ses_complaint_callback_with_missing_complaint_type,
|
||||
@@ -17,19 +14,8 @@ from tests.app.db import (
|
||||
)
|
||||
|
||||
|
||||
def test_ses_callback_should_not_set_status_once_status_is_delivered(client,
|
||||
notify_db,
|
||||
notify_db_session,
|
||||
sample_email_template,
|
||||
mocker):
|
||||
notification = create_sample_notification(
|
||||
notify_db,
|
||||
notify_db_session,
|
||||
template=sample_email_template,
|
||||
reference='ref',
|
||||
status='delivered',
|
||||
sent_at=datetime.utcnow()
|
||||
)
|
||||
def test_ses_callback_should_not_set_status_once_status_is_delivered(sample_email_template):
|
||||
notification = create_notification(sample_email_template, status='delivered', )
|
||||
|
||||
assert get_notification_by_id(notification.id).status == 'delivered'
|
||||
|
||||
|
||||
@@ -23,8 +23,6 @@ from app.notifications.process_notifications import (
|
||||
)
|
||||
from notifications_utils.recipients import validate_and_format_phone_number, validate_and_format_email_address
|
||||
from app.v2.errors import BadRequestError
|
||||
from tests.app.conftest import sample_api_key as create_api_key
|
||||
|
||||
from tests.app.db import create_service, create_template
|
||||
|
||||
|
||||
@@ -129,10 +127,8 @@ def test_cache_is_not_incremented_on_failure_to_persist_notification(sample_api_
|
||||
|
||||
|
||||
def test_persist_notification_does_not_increment_cache_if_test_key(
|
||||
notify_db, notify_db_session, sample_template, sample_job, mocker
|
||||
sample_template, sample_job, mocker, sample_test_api_key
|
||||
):
|
||||
api_key = create_api_key(notify_db=notify_db, notify_db_session=notify_db_session, service=sample_template.service,
|
||||
key_type='test')
|
||||
mocker.patch('app.notifications.process_notifications.redis_store.get', return_value="cache")
|
||||
mocker.patch('app.notifications.process_notifications.redis_store.get_all_from_hash', return_value="cache")
|
||||
daily_limit_cache = mocker.patch('app.notifications.process_notifications.redis_store.incr')
|
||||
@@ -147,8 +143,8 @@ def test_persist_notification_does_not_increment_cache_if_test_key(
|
||||
service=sample_template.service,
|
||||
personalisation={},
|
||||
notification_type='sms',
|
||||
api_key_id=api_key.id,
|
||||
key_type=api_key.key_type,
|
||||
api_key_id=sample_test_api_key.id,
|
||||
key_type=sample_test_api_key.key_type,
|
||||
job_id=sample_job.id,
|
||||
job_row_number=100,
|
||||
reference="ref",
|
||||
@@ -472,26 +468,24 @@ def test_persist_email_notification_stores_normalised_email(
|
||||
)
|
||||
def test_persist_letter_notification_finds_correct_postage(
|
||||
mocker,
|
||||
notify_db,
|
||||
notify_db_session,
|
||||
postage_argument,
|
||||
template_postage,
|
||||
expected_postage
|
||||
expected_postage,
|
||||
sample_service_full_permissions,
|
||||
sample_api_key,
|
||||
):
|
||||
service = create_service(service_permissions=[LETTER_TYPE])
|
||||
api_key = create_api_key(notify_db, notify_db_session, service=service)
|
||||
template = create_template(service, template_type=LETTER_TYPE, postage=template_postage)
|
||||
template = create_template(sample_service_full_permissions, template_type=LETTER_TYPE, postage=template_postage)
|
||||
mocker.patch('app.dao.templates_dao.dao_get_template_by_id', return_value=template)
|
||||
persist_notification(
|
||||
template_id=template.id,
|
||||
template_version=template.version,
|
||||
template_postage=template.postage,
|
||||
recipient="Jane Doe, 10 Downing Street, London",
|
||||
service=service,
|
||||
service=sample_service_full_permissions,
|
||||
personalisation=None,
|
||||
notification_type=LETTER_TYPE,
|
||||
api_key_id=api_key.id,
|
||||
key_type=api_key.key_type,
|
||||
api_key_id=sample_api_key.id,
|
||||
key_type=sample_api_key.key_type,
|
||||
postage=postage_argument
|
||||
)
|
||||
persisted_notification = Notification.query.all()[0]
|
||||
|
||||
@@ -17,7 +17,6 @@ from app.notifications.receive_notifications import (
|
||||
from app.models import InboundSms, EMAIL_TYPE, SMS_TYPE, INBOUND_SMS_TYPE
|
||||
from tests.conftest import set_config
|
||||
from tests.app.db import create_inbound_number, create_service, create_service_with_inbound_number
|
||||
from tests.app.conftest import sample_service
|
||||
|
||||
|
||||
def firetext_post(client, data, auth=True, password='testkey'):
|
||||
@@ -132,9 +131,8 @@ def test_receive_notification_from_firetext_without_permissions_does_not_persist
|
||||
|
||||
|
||||
def test_receive_notification_without_permissions_does_not_create_inbound_even_with_inbound_number_set(
|
||||
client, mocker, notify_db, notify_db_session):
|
||||
service = sample_service(notify_db, notify_db_session, permissions=[SMS_TYPE])
|
||||
inbound_number = create_inbound_number('1', service_id=service.id, active=True)
|
||||
client, mocker, sample_service):
|
||||
inbound_number = create_inbound_number('1', service_id=sample_service.id, active=True)
|
||||
|
||||
mocked_send_inbound_sms = mocker.patch(
|
||||
"app.notifications.receive_notifications.tasks.send_inbound_sms_to_service.apply_async")
|
||||
|
||||
@@ -6,11 +6,8 @@ from app.dao.services_dao import dao_add_user_to_service
|
||||
from app.models import Notification, EMAIL_TYPE, SMS_TYPE
|
||||
from app.service.sender import send_notification_to_service_users
|
||||
|
||||
from tests.app.conftest import (
|
||||
notify_service as create_notify_service,
|
||||
sample_service as create_sample_service
|
||||
)
|
||||
from tests.app.db import create_template, create_user
|
||||
from tests.app.conftest import notify_service as create_notify_service
|
||||
from tests.app.db import create_service, create_template, create_user
|
||||
|
||||
|
||||
@pytest.mark.parametrize('notification_type', [
|
||||
@@ -21,16 +18,16 @@ def test_send_notification_to_service_users_persists_notifications_correctly(
|
||||
notify_db,
|
||||
notify_db_session,
|
||||
notification_type,
|
||||
sample_user,
|
||||
sample_service,
|
||||
mocker
|
||||
):
|
||||
mocker.patch('app.service.sender.send_notification_to_queue')
|
||||
|
||||
notify_service, user = create_notify_service(notify_db, notify_db_session)
|
||||
service = create_sample_service(notify_db, notify_db_session, user=sample_user)
|
||||
template = create_template(service, template_type=notification_type)
|
||||
send_notification_to_service_users(service_id=service.id, template_id=template.id)
|
||||
to = sample_user.email_address if notification_type == EMAIL_TYPE else sample_user.mobile_number
|
||||
notify_service, _ = create_notify_service(notify_db, notify_db_session)
|
||||
user = sample_service.users[0]
|
||||
template = create_template(sample_service, template_type=notification_type)
|
||||
send_notification_to_service_users(service_id=sample_service.id, template_id=template.id)
|
||||
to = user.email_address if notification_type == EMAIL_TYPE else user.mobile_number
|
||||
|
||||
notification = Notification.query.one()
|
||||
|
||||
@@ -46,15 +43,14 @@ def test_send_notification_to_service_users_persists_notifications_correctly(
|
||||
def test_send_notification_to_service_users_sends_to_queue(
|
||||
notify_db,
|
||||
notify_db_session,
|
||||
sample_user,
|
||||
sample_service,
|
||||
mocker
|
||||
):
|
||||
send_mock = mocker.patch('app.service.sender.send_notification_to_queue')
|
||||
|
||||
create_notify_service(notify_db, notify_db_session)
|
||||
service = create_sample_service(notify_db, notify_db_session, user=sample_user)
|
||||
template = create_template(service, template_type=EMAIL_TYPE)
|
||||
send_notification_to_service_users(service_id=service.id, template_id=template.id)
|
||||
template = create_template(sample_service, template_type=EMAIL_TYPE)
|
||||
send_notification_to_service_users(service_id=sample_service.id, template_id=template.id)
|
||||
|
||||
assert send_mock.called
|
||||
assert send_mock.call_count == 1
|
||||
@@ -63,17 +59,18 @@ def test_send_notification_to_service_users_sends_to_queue(
|
||||
def test_send_notification_to_service_users_includes_user_fields_in_personalisation(
|
||||
notify_db,
|
||||
notify_db_session,
|
||||
sample_user,
|
||||
sample_service,
|
||||
mocker
|
||||
):
|
||||
persist_mock = mocker.patch('app.service.sender.persist_notification')
|
||||
mocker.patch('app.service.sender.send_notification_to_queue')
|
||||
|
||||
create_notify_service(notify_db, notify_db_session)
|
||||
service = create_sample_service(notify_db, notify_db_session, user=sample_user)
|
||||
template = create_template(service, template_type=EMAIL_TYPE)
|
||||
user = sample_service.users[0]
|
||||
|
||||
template = create_template(sample_service, template_type=EMAIL_TYPE)
|
||||
send_notification_to_service_users(
|
||||
service_id=service.id,
|
||||
service_id=sample_service.id,
|
||||
template_id=template.id,
|
||||
include_user_fields=['name', 'email_address', 'state']
|
||||
)
|
||||
@@ -82,9 +79,9 @@ def test_send_notification_to_service_users_includes_user_fields_in_personalisat
|
||||
|
||||
assert len(persist_mock.call_args_list) == 1
|
||||
assert persist_call['personalisation'] == {
|
||||
'name': sample_user.name,
|
||||
'email_address': sample_user.email_address,
|
||||
'state': sample_user.state,
|
||||
'name': user.name,
|
||||
'email_address': user.email_address,
|
||||
'state': user.state,
|
||||
}
|
||||
|
||||
|
||||
@@ -100,7 +97,7 @@ def test_send_notification_to_service_users_sends_to_active_users_only(
|
||||
first_active_user = create_user(email='foo@bar.com', state='active')
|
||||
second_active_user = create_user(email='foo1@bar.com', state='active')
|
||||
pending_user = create_user(email='foo2@bar.com', state='pending')
|
||||
service = create_sample_service(notify_db, notify_db_session, user=first_active_user)
|
||||
service = create_service(user=first_active_user)
|
||||
dao_add_user_to_service(service, second_active_user)
|
||||
dao_add_user_to_service(service, pending_user)
|
||||
template = create_template(service, template_type=EMAIL_TYPE)
|
||||
|
||||
@@ -23,7 +23,6 @@ from app.models import (
|
||||
from app.dao.templates_dao import dao_get_template_by_id, dao_redact_template
|
||||
|
||||
from tests import create_authorization_header
|
||||
from tests.app.conftest import sample_template as create_sample_template
|
||||
from tests.app.db import (
|
||||
create_service, create_letter_contact, create_template, create_notification,
|
||||
create_template_folder,
|
||||
@@ -520,21 +519,17 @@ def test_should_get_only_templates_for_that_service(admin_request, notify_db_ses
|
||||
]
|
||||
)
|
||||
def test_should_get_a_single_template(
|
||||
notify_db,
|
||||
client,
|
||||
sample_user,
|
||||
service_factory,
|
||||
sample_service,
|
||||
subject,
|
||||
content,
|
||||
template_type
|
||||
):
|
||||
|
||||
template = create_sample_template(
|
||||
notify_db, notify_db.session, subject_line=subject, content=content, template_type=template_type
|
||||
)
|
||||
template = create_template(sample_service, template_type=template_type, subject=subject, content=content)
|
||||
|
||||
response = client.get(
|
||||
'/service/{}/template/{}'.format(template.service.id, template.id),
|
||||
'/service/{}/template/{}'.format(sample_service.id, template.id),
|
||||
headers=[create_authorization_header()]
|
||||
)
|
||||
|
||||
@@ -583,10 +578,8 @@ def test_should_get_a_single_template(
|
||||
]
|
||||
)
|
||||
def test_should_preview_a_single_template(
|
||||
notify_db,
|
||||
client,
|
||||
sample_user,
|
||||
service_factory,
|
||||
sample_service,
|
||||
subject,
|
||||
content,
|
||||
path,
|
||||
@@ -594,13 +587,10 @@ def test_should_preview_a_single_template(
|
||||
expected_content,
|
||||
expected_error
|
||||
):
|
||||
|
||||
template = create_sample_template(
|
||||
notify_db, notify_db.session, subject_line=subject, content=content, template_type=EMAIL_TYPE
|
||||
)
|
||||
template = create_template(sample_service, template_type=EMAIL_TYPE, subject=subject, content=content)
|
||||
|
||||
response = client.get(
|
||||
path.format(template.service.id, template.id),
|
||||
path.format(sample_service.id, template.id),
|
||||
headers=[create_authorization_header()]
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user