mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
fix: sqlalchemy sessions per request
Best practice for web-apps is to have a session per web request. Instead of having a per worker-thread, we add a middleware that generates a unique ID per request, utilizing scoped_sessions scopefunc (custom function for defining a session scope) in combination with a ContextVar. With this we create a new session per request. Signed-off-by: moson <moson@archlinux.org>
This commit is contained in:
parent
d7ecede2eb
commit
3558c6ae5c
8 changed files with 94 additions and 19 deletions
|
@ -649,6 +649,7 @@ def test_orphan_request(
|
|||
assert resp.headers.get("location") == f"/pkgbase/{pkgbase.Name}"
|
||||
|
||||
# We should have unset the maintainer.
|
||||
db.refresh(pkgbase)
|
||||
assert pkgbase.Maintainer is None
|
||||
|
||||
# We should have removed the comaintainers.
|
||||
|
@ -748,6 +749,7 @@ def test_orphan_as_maintainer(client: TestClient, auser: User, pkgbase: PackageB
|
|||
# As the pkgbase maintainer, disowning the package just ends up
|
||||
# either promoting the lowest priority comaintainer or removing
|
||||
# the associated maintainer relationship altogether.
|
||||
db.refresh(pkgbase)
|
||||
assert pkgbase.Maintainer is None
|
||||
|
||||
|
||||
|
@ -1044,6 +1046,7 @@ def test_requests_close_post(client: TestClient, user: User, pkgreq: PackageRequ
|
|||
resp = request.post(f"/requests/{pkgreq.ID}/close")
|
||||
assert resp.status_code == int(HTTPStatus.SEE_OTHER)
|
||||
|
||||
db.refresh(pkgreq)
|
||||
assert pkgreq.Status == REJECTED_ID
|
||||
assert pkgreq.Closer == user
|
||||
assert pkgreq.ClosureComment == str()
|
||||
|
@ -1060,6 +1063,7 @@ def test_requests_close_post_rejected(
|
|||
)
|
||||
assert resp.status_code == int(HTTPStatus.SEE_OTHER)
|
||||
|
||||
db.refresh(pkgreq)
|
||||
assert pkgreq.Status == REJECTED_ID
|
||||
assert pkgreq.Closer == user
|
||||
assert pkgreq.ClosureComment == str()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue