Gib ein Uebergabepaket aus der bestaetigten Auswahl aus.
Die Dev-Umgebung soll die hierarchische Auswahl und das Paket pruefen koennen. Vorhandene Symbolaktionen der Inhaltszeilen bleiben im selben Stand. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
7626c56f3d
commit
27cde035e8
21 files changed
+2427
-54
No files matched your search
+31
-13
@@ -8,6 +8,7 @@ from __future__ import annotations
|
||||
|
||||
import os
|
||||
import tempfile
|
||||
import time
|
||||
|
||||
import psycopg
|
||||
import pytest
|
||||
@@ -28,17 +29,31 @@ os.environ["MEDIA_ROOT"] = tempfile.mkdtemp(prefix="tsumugu-pytest-")
|
||||
|
||||
|
||||
def _reset(settings) -> None:
|
||||
with psycopg.connect(settings.dsn(), autocommit=True) as conn:
|
||||
conn.execute(
|
||||
"""
|
||||
TRUNCATE TABLE
|
||||
media_operations,
|
||||
domain_events,
|
||||
auth_accounts,
|
||||
data_rooms
|
||||
RESTART IDENTITY CASCADE
|
||||
"""
|
||||
)
|
||||
# The suite truncates between tests while the app pool may still release
|
||||
# the previous request's transaction. A deadlock abort would roll back that
|
||||
# transaction and the next login would fail. Waiting and retrying keeps the
|
||||
# reset outside the product path.
|
||||
last_error: Exception | None = None
|
||||
for attempt in range(8):
|
||||
try:
|
||||
with psycopg.connect(settings.dsn(), autocommit=True) as conn:
|
||||
conn.execute("SET lock_timeout = '1500ms'")
|
||||
conn.execute(
|
||||
"""
|
||||
TRUNCATE TABLE
|
||||
media_operations,
|
||||
domain_events,
|
||||
auth_accounts,
|
||||
data_rooms
|
||||
RESTART IDENTITY CASCADE
|
||||
"""
|
||||
)
|
||||
return
|
||||
except (psycopg.errors.DeadlockDetected, psycopg.errors.LockNotAvailable) as exc:
|
||||
last_error = exc
|
||||
time.sleep(0.15 * (attempt + 1))
|
||||
if last_error is not None:
|
||||
raise last_error
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
@@ -83,6 +98,9 @@ def clean(database, client):
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def db(database):
|
||||
def db(database, clean):
|
||||
with psycopg.connect(database.dsn(), row_factory=psycopg.rows.dict_row) as conn:
|
||||
yield conn
|
||||
try:
|
||||
yield conn
|
||||
finally:
|
||||
conn.rollback()
|
||||
Reference in new issue
Block a user