Skip to content

Commit

Permalink
fix: cookie_app and users not using same app
Browse files Browse the repository at this point in the history
* the problem is since cookie_app and users use different app one closes
  the connection to the database first which is bad
  • Loading branch information
utnapischtim committed Dec 4, 2024
1 parent a5ef3a3 commit f3c054d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
17 changes: 3 additions & 14 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ def _app_factory(config=None):
ACCOUNTS_SETTINGS_TEMPLATE="invenio_accounts/settings/base.html",
ACCOUNTS_COVER_TEMPLATE="invenio_accounts/base_cover.html",
WEBPACKEXT_MANIFEST_LOADER=MockManifestLoader,
SESSION_COOKIE_SECURE=True,
SESSION_COOKIE_DOMAIN="example.com",
)

app.config.update(config or {})
Expand Down Expand Up @@ -213,6 +215,7 @@ def api(request):
),
SERVER_NAME="localhost",
TESTING=True,
SESSION_COOKIE_DOMAIN="localhost",
)
)

Expand Down Expand Up @@ -277,20 +280,6 @@ def task_app(request):
return app


@pytest.fixture
def cookie_app(request):
"""Flask application enabled."""
app = _app_factory(
dict(
SESSION_COOKIE_SECURE=True,
SESSION_COOKIE_DOMAIN="example.com",
)
)
InvenioAccounts(app)
_database_setup(app, request)
return app


@pytest.fixture
def admin_view(app):
"""Admin view fixture."""
Expand Down
4 changes: 2 additions & 2 deletions tests/test_invenio_accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,11 @@ def test_configuration(base_app):
assert "deadbeef" == app.config["ACCOUNTS_USE_CELERY"]


def test_cookies(cookie_app, users):
def test_cookies(app, users):
"""Test cookies set on login."""
u = users[0]

with cookie_app.test_client() as client:
with app.test_client() as client:
res = client.post(
url_for_security("login"),
data=dict(email=u["email"], password=u["password"], remember=True),
Expand Down

0 comments on commit f3c054d

Please sign in to comment.