Read the API key list before the next query replaces it.
Deploy Development / deploy (push) Successful in 54s
Test Suite / pytest-backend (push) Failing after 29s
Test Suite / lint-backend (push) Successful in 1s
Test Suite / build-frontend (push) Successful in 23s
Test Suite / k6 /health Baseline (push) Successful in 35s
Test Suite / playwright-tests (push) Failing after 7m41s
Deploy Development / deploy (push) Successful in 54s
Test Suite / pytest-backend (push) Failing after 29s
Test Suite / lint-backend (push) Successful in 1s
Test Suite / build-frontend (push) Successful in 23s
Test Suite / k6 /health Baseline (push) Successful in 35s
Test Suite / playwright-tests (push) Failing after 7m41s
The exercise release screen asked which keys match and then looked up club roles on the same cursor. The key rows were discarded, so a valid key looked missing. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
b824115e9b
commit
4b33b17b2d
3 files changed
+56
-5
No files matched your search
@@ -14,7 +14,7 @@ from fastapi.testclient import TestClient
|
||||
os.environ.setdefault("SKIP_DB_MIGRATE", "1")
|
||||
|
||||
from auth import require_auth
|
||||
from distribution_service import _lock_recipient
|
||||
from distribution_service import _lock_recipient, release_keys_for_exercise
|
||||
from distribution_contract import (
|
||||
InvalidCursor,
|
||||
actions_cover,
|
||||
@@ -237,6 +237,50 @@ def test_distribution_read_is_hidden_while_disabled(client: TestClient, monkeypa
|
||||
assert response.headers.get("cache-control") == "private, no-store"
|
||||
|
||||
|
||||
class _DroppingCursor:
|
||||
"""Ein neues execute verwirft ein noch nicht gelesenes Ergebnis, wie psycopg2."""
|
||||
|
||||
def __init__(self, key: dict) -> None:
|
||||
self._key = key
|
||||
self._pending = None
|
||||
|
||||
def execute(self, sql, _params=None):
|
||||
if self._pending is not None:
|
||||
raise AssertionError("Ergebnis wurde vor dem Lesen überschrieben")
|
||||
self._pending = [self._key] if "FROM distribution_keys" in sql else []
|
||||
|
||||
def fetchall(self):
|
||||
rows = self._pending
|
||||
self._pending = None
|
||||
return rows or []
|
||||
|
||||
def fetchone(self):
|
||||
rows = self.fetchall()
|
||||
return rows[0] if rows else None
|
||||
|
||||
|
||||
def test_release_screen_keeps_the_application_key() -> None:
|
||||
key = {
|
||||
"id": "key-1",
|
||||
"label": "Lara",
|
||||
"context_kind": "user",
|
||||
"context_club_id": None,
|
||||
"context_profile_id": 7,
|
||||
"club_ids": [3],
|
||||
"recipient_id": "rec-1",
|
||||
"api_enabled": True,
|
||||
}
|
||||
cur = _DroppingCursor(key)
|
||||
keys, block = release_keys_for_exercise(
|
||||
cur,
|
||||
{"visibility": "official", "club_id": None, "created_by": 7},
|
||||
7,
|
||||
"superadmin",
|
||||
)
|
||||
assert block is None
|
||||
assert [item["label"] for item in keys] == ["Lara"]
|
||||
|
||||
|
||||
def test_channel_sequence_is_locked() -> None:
|
||||
assert "FOR UPDATE" in inspect.getsource(_lock_recipient)
|
||||
|
||||
|
||||
Reference in new issue
Block a user