Create fixture that just calls create_app

This commit is contained in:
Ryan Ahearn
2022-12-13 08:53:41 -05:00
parent 0d0db5f6f6
commit 6aa46da916
2 changed files with 10 additions and 6 deletions

View File

@@ -154,7 +154,7 @@ def test_notification_personalisation_getter_returns_empty_dict_from_None():
assert noti.personalisation == {} 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 = Notification()
noti._personalisation = encryption.encrypt({}) noti._personalisation = encryption.encrypt({})
assert noti.personalisation == {} assert noti.personalisation == {}
@@ -164,7 +164,7 @@ def test_notification_personalisation_getter_always_returns_empty_dict(notify_ap
None, 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 = Notification()
noti.personalisation = input_value noti.personalisation = input_value

View File

@@ -12,16 +12,20 @@ from app.dao.provider_details_dao import get_provider_details_by_identifier
@pytest.fixture(scope='session') @pytest.fixture(scope='session')
def notify_api(): def notify_app():
app = Flask('test') app = Flask('test')
create_app(app) create_app(app)
return app
@pytest.fixture(scope='session')
def notify_api(notify_app):
# deattach server-error error handlers - error_handler_spec looks like: # deattach server-error error handlers - error_handler_spec looks like:
# {'blueprint_name': { # {'blueprint_name': {
# status_code: [error_handlers], # status_code: [error_handlers],
# None: { ExceptionClass: error_handler } # 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) error_handlers.pop(500, None)
if None in error_handlers: if None in error_handlers:
error_handlers[None] = { error_handlers[None] = {
@@ -32,10 +36,10 @@ def notify_api():
if error_handlers[None] == []: if error_handlers[None] == []:
error_handlers.pop(None) error_handlers.pop(None)
ctx = app.app_context() ctx = notify_app.app_context()
ctx.push() ctx.push()
yield app yield notify_app
ctx.pop() ctx.pop()