Skip to content

Commit 47e8ed9

Browse files
committed
fix: cookie_app and users not using same app
* the problem is since cookie_app and users use different app one closes the connection to the database first which is bad
1 parent 3527d89 commit 47e8ed9

File tree

2 files changed

+5
-16
lines changed

2 files changed

+5
-16
lines changed

tests/conftest.py

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ def _app_factory(config=None):
119119
ACCOUNTS_SETTINGS_TEMPLATE="invenio_accounts/settings/base.html",
120120
ACCOUNTS_COVER_TEMPLATE="invenio_accounts/base_cover.html",
121121
WEBPACKEXT_MANIFEST_LOADER=MockManifestLoader,
122+
SESSION_COOKIE_SECURE=True,
123+
SESSION_COOKIE_DOMAIN="example.com",
122124
)
123125

124126
app.config.update(config or {})
@@ -213,6 +215,7 @@ def api(request):
213215
),
214216
SERVER_NAME="localhost",
215217
TESTING=True,
218+
SESSION_COOKIE_DOMAIN="localhost",
216219
)
217220
)
218221

@@ -277,20 +280,6 @@ def task_app(request):
277280
return app
278281

279282

280-
@pytest.fixture
281-
def cookie_app(request):
282-
"""Flask application enabled."""
283-
app = _app_factory(
284-
dict(
285-
SESSION_COOKIE_SECURE=True,
286-
SESSION_COOKIE_DOMAIN="example.com",
287-
)
288-
)
289-
InvenioAccounts(app)
290-
_database_setup(app, request)
291-
return app
292-
293-
294283
@pytest.fixture
295284
def admin_view(app):
296285
"""Admin view fixture."""

tests/test_invenio_accounts.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,11 +222,11 @@ def test_configuration(base_app):
222222
assert "deadbeef" == app.config["ACCOUNTS_USE_CELERY"]
223223

224224

225-
def test_cookies(cookie_app, users):
225+
def test_cookies(app, users):
226226
"""Test cookies set on login."""
227227
u = users[0]
228228

229-
with cookie_app.test_client() as client:
229+
with app.test_client() as client:
230230
res = client.post(
231231
url_for_security("login"),
232232
data=dict(email=u["email"], password=u["password"], remember=True),

0 commit comments

Comments
 (0)