diff --git a/tests/features/access_private_data.feature b/tests/features/access_private_data.feature index aff2d18..225cfa6 100644 --- a/tests/features/access_private_data.feature +++ b/tests/features/access_private_data.feature @@ -1,6 +1,7 @@ Feature: Access protected information @fixture.settings_auth + @fixture.session_factory @fixture.test_client Scenario: Access protected information as logged-in user Given I am logged in as a user @@ -8,6 +9,7 @@ Feature: Access protected information Then I get access to private data @fixture.settings_auth + @fixture.session_factory @fixture.test_client Scenario: Access protected information as anonymous user Given I am not logged in as a user diff --git a/tests/features/environment.py b/tests/features/environment.py index 7dc7f8e..c009aa3 100644 --- a/tests/features/environment.py +++ b/tests/features/environment.py @@ -1,10 +1,12 @@ from behave import use_fixture -from tests.features.fixtures import settings_auth, test_client +from tests.features.fixtures import session_factory, settings_auth, test_client def before_tag(context, tag): if tag == "fixture.settings_auth": use_fixture(settings_auth, context) + elif tag == "fixture.session_factory": + use_fixture(session_factory, context) elif tag == "fixture.test_client": use_fixture(test_client, context) diff --git a/tests/features/fixtures.py b/tests/features/fixtures.py index e65f5ae..e23fdd8 100644 --- a/tests/features/fixtures.py +++ b/tests/features/fixtures.py @@ -1,7 +1,7 @@ from behave import fixture from fastapi.testclient import TestClient -from in_concert.app.app_factory import create_app +from in_concert.app.app_factory import create_app, get_db_session_factory from in_concert.settings import Auth0Settings, Auth0SettingsTest @@ -12,9 +12,15 @@ def settings_auth(context) -> Auth0Settings: return context.settings_auth +@fixture +def session_factory(context): + context.session_factory = get_db_session_factory(context.settings_auth) + return context.session_factory + + @fixture def test_client(context): - app = create_app(context.settings_auth) + app = create_app(context.settings_auth, context.session_factory) test_client = TestClient(app) context.test_client = test_client return context.test_client