test: no test throws a response away; the stream session is narrowed, not baselined
The 7 baselined Optional accesses in plex/stream.py were one fact the type did not carry: the initial spawn (replace_only=None) always supersedes, so only the fallback respawn can get None. An assert at the call site says so; the pyright baseline drops 195 -> 188. test_abuse_limits: the public-URL and YouTube enqueue tests stopped at the profile lookup (400 no_profile) and passed on that unrelated refusal. They now send an inline spec and assert the job is queued. The same shape — a request whose response is discarded — sat at 53 more places across the suite (all returned what they should, measured with a TestClient probe); each now asserts its status, and test_response_checked keeps it that way (seen red).
This commit is contained in:
@@ -151,7 +151,7 @@ def test_nobody_reaches_another_users_session(db, make_user, as_user):
|
||||
def test_the_list_is_the_users_own_newest_first(db, make_user, as_user):
|
||||
client = as_user(make_user())
|
||||
first = _start(client)["id"]
|
||||
client.post(f"/api/debug-sessions/{first}/stop")
|
||||
assert client.post(f"/api/debug-sessions/{first}/stop").status_code == 200
|
||||
second = _start(client)["id"]
|
||||
assert [s["id"] for s in client.get("/api/debug-sessions").json()["items"]] == [second, first]
|
||||
|
||||
@@ -199,10 +199,13 @@ def test_an_erased_account_takes_its_sessions_with_it(db, make_user, as_user):
|
||||
user = make_user()
|
||||
client = as_user(user)
|
||||
sid = _start(client)["id"]
|
||||
client.post(
|
||||
f"/api/debug-sessions/{sid}/screenshots",
|
||||
content=_PNG,
|
||||
headers={"content-type": "image/png"},
|
||||
assert (
|
||||
client.post(
|
||||
f"/api/debug-sessions/{sid}/screenshots",
|
||||
content=_PNG,
|
||||
headers={"content-type": "image/png"},
|
||||
).status_code
|
||||
== 200
|
||||
)
|
||||
purge_user(db, user, BackgroundTasks())
|
||||
assert db.get(DebugSession, sid) is None
|
||||
@@ -250,7 +253,7 @@ def test_a_request_naming_the_own_open_session_is_tagged_and_raised(gated, db, c
|
||||
_signed_in(client, make_user)
|
||||
sid = _start(client, "DEBUG")["id"]
|
||||
gated.records.clear()
|
||||
client.get("/api/debug-sessions", headers={"x-debug-session": sid})
|
||||
assert client.get("/api/debug-sessions", headers={"x-debug-session": sid}).status_code == 200
|
||||
(line,) = _request_lines(gated)
|
||||
assert getattr(line, "debug_session_id", None) == sid
|
||||
# Raised to the session's level: the line is kept for storage though the user's own is Alap.
|
||||
@@ -263,7 +266,7 @@ def test_a_header_naming_anything_else_is_ignored_not_refused(gated, db, client,
|
||||
db.commit()
|
||||
_signed_in(client, make_user)
|
||||
own = _start(client)["id"]
|
||||
client.post(f"/api/debug-sessions/{own}/stop")
|
||||
assert client.post(f"/api/debug-sessions/{own}/stop").status_code == 200
|
||||
for value in (foreign, own, "not-a-session", "f" * 16, "A" * 16):
|
||||
gated.records.clear()
|
||||
# Not `/api/me`: a polled route logs at DEBUG, and an un-raised request would drop the very
|
||||
@@ -280,7 +283,7 @@ def test_a_header_naming_the_own_session_past_its_cap_is_ignored(gated, db, clie
|
||||
sid = _start(client)["id"]
|
||||
_expire(db, sid) # past its cap, not yet swept: still open in the table
|
||||
gated.records.clear()
|
||||
client.get("/api/debug-sessions", headers={"x-debug-session": sid})
|
||||
assert client.get("/api/debug-sessions", headers={"x-debug-session": sid}).status_code == 200
|
||||
(line,) = _request_lines(gated)
|
||||
assert getattr(line, "debug_session_id", None) is None
|
||||
assert getattr(line, "elevated", False) is False
|
||||
@@ -616,7 +619,7 @@ def test_a_users_screenshots_are_capped_across_their_sessions(recording, monkeyp
|
||||
client, sid = recording
|
||||
monkeypatch.setattr(debugsession, "SCREENSHOT_USER_MAX_BYTES", len(_PNG) * 2)
|
||||
assert _upload(client, sid, _PNG).status_code == 200
|
||||
client.post(f"/api/debug-sessions/{sid}/stop")
|
||||
assert client.post(f"/api/debug-sessions/{sid}/stop").status_code == 200
|
||||
other = _start(client)["id"]
|
||||
assert _upload(client, other, _PNG).status_code == 200
|
||||
r = _upload(client, other, _PNG)
|
||||
@@ -631,7 +634,7 @@ def test_new_sessions_are_paced_but_joining_one_is_not(db, make_user, as_user, m
|
||||
client = as_user(make_user())
|
||||
sid = _start(client)["id"]
|
||||
assert _start(client)["id"] == sid # another tab joining
|
||||
client.post(f"/api/debug-sessions/{sid}/stop")
|
||||
assert client.post(f"/api/debug-sessions/{sid}/stop").status_code == 200
|
||||
r = client.post("/api/debug-sessions", json={"level": "DEBUG"})
|
||||
assert r.status_code == 429 and r.json()["detail"]["reason"] == "debug_session_rate_limited"
|
||||
|
||||
@@ -745,9 +748,16 @@ def test_the_export_is_the_saved_draft_the_evidence_and_the_screenshots(db, make
|
||||
db.commit()
|
||||
_upload(client, sid, _PNG)
|
||||
_upload(client, sid, _JPEG)
|
||||
client.put(
|
||||
f"/api/debug-sessions/{sid}/draft",
|
||||
json={"title": "Spinner stays", "body": "It spins.", "excluded": [dropped_web.id, 999999]},
|
||||
assert (
|
||||
client.put(
|
||||
f"/api/debug-sessions/{sid}/draft",
|
||||
json={
|
||||
"title": "Spinner stays",
|
||||
"body": "It spins.",
|
||||
"excluded": [dropped_web.id, 999999],
|
||||
},
|
||||
).status_code
|
||||
== 200
|
||||
)
|
||||
|
||||
r = client.get(f"/api/debug-sessions/{sid}/export")
|
||||
@@ -1144,7 +1154,7 @@ def test_new_issues_are_paced_per_user(gitea_fake, db, make_user, as_user, monke
|
||||
first = _start(client)["id"]
|
||||
_ready(client, first)
|
||||
assert client.post(f"/api/debug-sessions/{first}/issue").status_code == 200
|
||||
client.post(f"/api/debug-sessions/{first}/stop")
|
||||
assert client.post(f"/api/debug-sessions/{first}/stop").status_code == 200
|
||||
second = _start(client)["id"]
|
||||
_ready(client, second)
|
||||
r = client.post(f"/api/debug-sessions/{second}/issue")
|
||||
|
||||
Reference in New Issue
Block a user