From 6aa46da91680d8b93ef4562b6c8be92ee82d3a07 Mon Sep 17 00:00:00 2001 From: Ryan Ahearn Date: Tue, 13 Dec 2022 08:53:41 -0500 Subject: [PATCH] Create fixture that just calls create_app --- tests/app/test_model.py | 4 ++-- tests/conftest.py | 12 ++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/tests/app/test_model.py b/tests/app/test_model.py index a7f394db9..3a98831da 100644 --- a/tests/app/test_model.py +++ b/tests/app/test_model.py @@ -154,7 +154,7 @@ def test_notification_personalisation_getter_returns_empty_dict_from_None(): assert noti.personalisation == {} -def test_notification_personalisation_getter_always_returns_empty_dict(notify_api): +def test_notification_personalisation_getter_always_returns_empty_dict(notify_app): noti = Notification() noti._personalisation = encryption.encrypt({}) assert noti.personalisation == {} @@ -164,7 +164,7 @@ def test_notification_personalisation_getter_always_returns_empty_dict(notify_ap None, {} ]) -def test_notification_personalisation_setter_always_sets_empty_dict(notify_api, input_value): +def test_notification_personalisation_setter_always_sets_empty_dict(notify_app, input_value): noti = Notification() noti.personalisation = input_value diff --git a/tests/conftest.py b/tests/conftest.py index dabd3eb33..12dfb3710 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -12,16 +12,20 @@ from app.dao.provider_details_dao import get_provider_details_by_identifier @pytest.fixture(scope='session') -def notify_api(): +def notify_app(): app = Flask('test') create_app(app) + return app + +@pytest.fixture(scope='session') +def notify_api(notify_app): # deattach server-error error handlers - error_handler_spec looks like: # {'blueprint_name': { # status_code: [error_handlers], # None: { ExceptionClass: error_handler } # }} - for error_handlers in app.error_handler_spec.values(): + for error_handlers in notify_app.error_handler_spec.values(): error_handlers.pop(500, None) if None in error_handlers: error_handlers[None] = { @@ -32,10 +36,10 @@ def notify_api(): if error_handlers[None] == []: error_handlers.pop(None) - ctx = app.app_context() + ctx = notify_app.app_context() ctx.push() - yield app + yield notify_app ctx.pop()