From a2c25cec9f8a463c021a4beba1dc62e6f65f7e37 Mon Sep 17 00:00:00 2001 From: Katie Smith Date: Wed, 18 Sep 2019 12:01:20 +0100 Subject: [PATCH] Make a couple of fixtures Pytest 4 compliant By stopping them from calling other fixtures as functions. --- tests/app/conftest.py | 41 ++++++++++++++--------------------------- 1 file changed, 14 insertions(+), 27 deletions(-) diff --git a/tests/app/conftest.py b/tests/app/conftest.py index fb395d756..5dd92364c 100644 --- a/tests/app/conftest.py +++ b/tests/app/conftest.py @@ -272,17 +272,15 @@ def sample_template_without_letter_permission(notify_db, notify_db_session): @pytest.fixture(scope='function') -def sample_template_with_placeholders(notify_db, notify_db_session): +def sample_template_with_placeholders(sample_service): # deliberate space and title case in placeholder - return sample_template(notify_db, notify_db_session, content="Hello (( Name))\nYour thing is due soon") + return create_template(sample_service, content="Hello (( Name))\nYour thing is due soon") @pytest.fixture(scope='function') -def sample_sms_template_with_html(notify_db, notify_db_session): +def sample_sms_template_with_html(sample_service): # deliberate space and title case in placeholder - return sample_template(notify_db, notify_db_session, content=( - "Hello (( Name))\nHere is some HTML & entities" - )) + return create_template(sample_service, content="Hello (( Name))\nHere is some HTML & entities") @pytest.fixture(scope='function') @@ -411,31 +409,20 @@ def sample_job( @pytest.fixture(scope='function') def sample_job_with_placeholdered_template( - notify_db, - notify_db_session, - service=None + sample_job, + sample_template_with_placeholders, ): - return sample_job( - notify_db, - notify_db_session, - service=service, - template=sample_template_with_placeholders(notify_db, notify_db_session) - ) + sample_job.template = sample_template_with_placeholders + + return sample_job @pytest.fixture(scope='function') -def sample_scheduled_job( - notify_db, - notify_db_session, - service=None -): - return sample_job( - notify_db, - notify_db_session, - service=service, - template=sample_template_with_placeholders(notify_db, notify_db_session), - scheduled_for=(datetime.utcnow() + timedelta(minutes=60)).isoformat(), - job_status='scheduled' +def sample_scheduled_job(sample_template_with_placeholders): + return create_job( + sample_template_with_placeholders, + job_status='scheduled', + scheduled_for=(datetime.utcnow() + timedelta(minutes=60)).isoformat() )