diff --git a/dashboard/dashboard.py b/dashboard/dashboard.py index 9ec36a4..cae406f 100644 --- a/dashboard/dashboard.py +++ b/dashboard/dashboard.py @@ -206,7 +206,11 @@ def _local_history_row(run_id, res): so render_history is unchanged. `number` is the run dir name (the /runs// path + _results_for key); link to the Drone build when the id is numeric, else to the local summary card.""" ref = res.get("ref") or "" - url = f"{DRONE_URL}/{CI_REPO}/{run_id}" if str(run_id).isdigit() else f"/runs/{run_id}/summary.html" + url = ( + f"{DRONE_URL}/{CI_REPO}/{run_id}" + if str(run_id).isdigit() + else f"/runs/{run_id}/summary.html" + ) return { "recipe": res.get("recipe"), "status": _run_status(res), @@ -351,7 +355,7 @@ def _card(r): f'
{shot}
' f'
{html.escape(r["recipe"])}
' f'
{html.escape(r["status"])}' - f'{html.escape(r["version"])}
' + f"{html.escape(r['version'])}
" f"{_flags_html(r['flags'])}" f'' @@ -394,7 +398,7 @@ def render_history(recipe, rows): f'#{r["number"]}' f'{html.escape(r["status"])}' f"{lvl}{html.escape(r['version'])}" - f'{_ago(r["finished"])}{shot}' + f"{_ago(r['finished'])}{shot}" ) body = "\n".join(trs) or 'no runs for this recipe yet' inner = ( diff --git a/runner/harness/card.py b/runner/harness/card.py index 562f8ba..6b1ca87 100644 --- a/runner/harness/card.py +++ b/runner/harness/card.py @@ -98,7 +98,7 @@ def _stage_rows(stages: list[dict]) -> str: scolor = STATUS_COLOR.get(st.get("status", ""), "#8b949e") rows.append( f'{smark}' - f'{html.escape(st.get("name", "?"))}' + f"{html.escape(st.get('name', '?'))}" f'{html.escape(st.get("status", ""))}' ) for t in st.get("tests", []): @@ -175,7 +175,7 @@ def render_card_html(data: dict, screenshot_rel: str | None = "screenshot.png") ok = bool(flags.get(key)) flag_bits.append( f'' - f'{STATUS_MARK["pass"] if ok else STATUS_MARK["fail"]} {lbl}' + f"{STATUS_MARK['pass'] if ok else STATUS_MARK['fail']} {lbl}" ) show_shot = bool(screenshot_rel) and bool(data.get("screenshot")) shot_html = ( diff --git a/tests/bluesky-pds/custom/test_account_and_post.py b/tests/bluesky-pds/custom/test_account_and_post.py index ea8604f..218ca73 100644 --- a/tests/bluesky-pds/custom/test_account_and_post.py +++ b/tests/bluesky-pds/custom/test_account_and_post.py @@ -88,9 +88,9 @@ def test_account_lifecycle_and_post_roundtrip(live_app): # Step 1: PDS describe via goat — recipe self-identifies as did:web: out = _in_container(domain, f"goat pds describe {PDS_HOST_LOCAL} 2>&1") - assert ( - f"did:web:{domain}" in out - ), f"goat pds describe did not contain expected DID 'did:web:{domain}'. Output:\n{out[:500]!r}" + assert f"did:web:{domain}" in out, ( + f"goat pds describe did not contain expected DID 'did:web:{domain}'. Output:\n{out[:500]!r}" + ) # Step 2: Create account (UUID-suffixed handle = no run-to-run collision) out = _goat_admin( @@ -133,9 +133,9 @@ def test_account_lifecycle_and_post_roundtrip(live_app): assert s == 200, f"createRecord HTTP {s}: {body!r}" record_uri = (body or {}).get("uri", "") # URI format: at:///app.bsky.feed.post/ - assert record_uri.startswith( - f"at://{new_did}/app.bsky.feed.post/" - ), f"unexpected record uri: {record_uri!r}" + assert record_uri.startswith(f"at://{new_did}/app.bsky.feed.post/"), ( + f"unexpected record uri: {record_uri!r}" + ) rkey = record_uri.rsplit("/", 1)[-1] assert rkey, f"no rkey in uri: {record_uri!r}" @@ -148,9 +148,9 @@ def test_account_lifecycle_and_post_roundtrip(live_app): ) assert s == 200, f"getRecord HTTP {s}: {body!r}" record_value = (body or {}).get("value", {}) - assert ( - record_value.get("text") == marker - ), f"post text did not round-trip: created={marker!r}, fetched={record_value.get('text')!r}" + assert record_value.get("text") == marker, ( + f"post text did not round-trip: created={marker!r}, fetched={record_value.get('text')!r}" + ) assert record_value.get("$type") == "app.bsky.feed.post" finally: # Step 6: Best-effort cleanup. (The per-run domain teardown will discard the volume diff --git a/tests/bluesky-pds/custom/test_describe_server.py b/tests/bluesky-pds/custom/test_describe_server.py index fd49524..c993ffe 100644 --- a/tests/bluesky-pds/custom/test_describe_server.py +++ b/tests/bluesky-pds/custom/test_describe_server.py @@ -26,6 +26,6 @@ def test_describe_server_returns_atproto_envelope(live_app): # At least one of these atproto-spec fields must be present expected_any = ("availableUserDomains", "inviteCodeRequired", "links", "did") present = [k for k in expected_any if k in body] - assert ( - present - ), f"describe-server missing all of {expected_any}; got keys: {sorted(body.keys())[:20]}" + assert present, ( + f"describe-server missing all of {expected_any}; got keys: {sorted(body.keys())[:20]}" + ) diff --git a/tests/bluesky-pds/custom/test_health_check.py b/tests/bluesky-pds/custom/test_health_check.py index 847ab3e..0fb19a3 100644 --- a/tests/bluesky-pds/custom/test_health_check.py +++ b/tests/bluesky-pds/custom/test_health_check.py @@ -17,6 +17,6 @@ def test_pds_health_returns_version(live_app): url = f"https://{live_app}/xrpc/_health" status, body = harness_http.retry_http_get(url, expect_status=200, max_wait=60, interval=3) assert status == 200, f"GET {url} HTTP {status} (expected 200)" - assert ( - isinstance(body, dict) and isinstance(body.get("version"), str) and body["version"] - ), f"GET {url} response is not the expected health envelope: {body!r}" + assert isinstance(body, dict) and isinstance(body.get("version"), str) and body["version"], ( + f"GET {url} response is not the expected health envelope: {body!r}" + ) diff --git a/tests/bluesky-pds/custom/test_session_auth.py b/tests/bluesky-pds/custom/test_session_auth.py index f26b417..da4c474 100644 --- a/tests/bluesky-pds/custom/test_session_auth.py +++ b/tests/bluesky-pds/custom/test_session_auth.py @@ -30,6 +30,6 @@ def test_get_session_requires_auth(live_app): f"body: {body!r}" ) # The XRPC error envelope is JSON with an `error` field per the atproto spec. - assert isinstance(body, dict) and body.get( - "error" - ), f"expected XRPC JSON error envelope; got: {body!r}" + assert isinstance(body, dict) and body.get("error"), ( + f"expected XRPC JSON error envelope; got: {body!r}" + ) diff --git a/tests/bluesky-pds/test_restore.py b/tests/bluesky-pds/test_restore.py index 6a7e798..7bfa04f 100644 --- a/tests/bluesky-pds/test_restore.py +++ b/tests/bluesky-pds/test_restore.py @@ -11,6 +11,6 @@ import _p4 # noqa: E402 def test_restore_returns_state(live_app): - assert _p4.account_exists( - live_app - ), "restore did not bring back the seeded marker account (PDS data did not survive restore)" + assert _p4.account_exists(live_app), ( + "restore did not bring back the seeded marker account (PDS data did not survive restore)" + ) diff --git a/tests/concurrency/test_janitor.py b/tests/concurrency/test_janitor.py index bdf61b9..330bf32 100644 --- a/tests/concurrency/test_janitor.py +++ b/tests/concurrency/test_janitor.py @@ -78,9 +78,9 @@ def test_7_new_run_blocks_until_reap_finishes(lock_dir, pool, monkeypatch): line = wait_marker(state["acquirer_out"], "ACQUIRED", timeout=15) assert line, "new run never acquired after the reap" acquired_ts = float(line.split()[1]) - assert ( - acquired_ts >= state["teardown_end"] - ), f"new run acquired at {acquired_ts} BEFORE the reap finished at {state['teardown_end']}" + assert acquired_ts >= state["teardown_end"], ( + f"new run acquired at {acquired_ts} BEFORE the reap finished at {state['teardown_end']}" + ) # The new run must hold a lock the next probe can SEE (fresh inode at the path). assert lock_state(DOMAIN) == "held" @@ -160,17 +160,17 @@ def test_11_warm_canonical_names_never_probed(lock_dir, monkeypatch): monkeypatch.setattr( lifecycle, "_docker_names", - lambda kind, stack: ["warm-keycloak_ci_commoninternet_net_app"] - if kind == "service" - else [], + lambda kind, stack: ( + ["warm-keycloak_ci_commoninternet_net_app"] if kind == "service" else [] + ), ) monkeypatch.setattr(lifecycle, "teardown_app", lambda d, verify=True: calls.append(d)) lifecycle.janitor() assert calls == [] lockdir = os.environ["CCCI_APP_LOCK_DIR"] - assert [ - f for f in os.listdir(lockdir) if f.startswith("cc-ci-app-") - ] == [], "janitor must not create lockfiles for non-run-app names" + assert [f for f in os.listdir(lockdir) if f.startswith("cc-ci-app-")] == [], ( + "janitor must not create lockfiles for non-run-app names" + ) def test_12_degrades_safely_on_bad_lockfile_and_missing_dir(lock_dir, monkeypatch, capsys): diff --git a/tests/concurrency/test_locks.py b/tests/concurrency/test_locks.py index 8059dbb..c49f475 100644 --- a/tests/concurrency/test_locks.py +++ b/tests/concurrency/test_locks.py @@ -61,9 +61,9 @@ def test_3_lock_fd_not_inherited_by_children(lock_dir, pool): p.kill() p.wait(timeout=10) assert os.path.exists(f"/proc/{child_pid}"), "child should outlive the holder" - assert ( - wait_lock_state(DOMAIN, "free") == "free" - ), "lock must release on holder death even with a live child (PEP 446 non-inheritable fd)" + assert wait_lock_state(DOMAIN, "free") == "free", ( + "lock must release on holder death even with a live child (PEP 446 non-inheritable fd)" + ) def test_4_second_acquire_blocks_until_first_exits(lock_dir, pool): diff --git a/tests/concurrency/test_run_state.py b/tests/concurrency/test_run_state.py index ca34b6b..d4482ba 100644 --- a/tests/concurrency/test_run_state.py +++ b/tests/concurrency/test_run_state.py @@ -64,9 +64,9 @@ def test_20c_same_domain_runs_each_keep_their_own_count(tmp_path, lock_dir, pool pa.wait(timeout=15) line_b = wait_marker(out_b, "COUNT") - assert ( - line_b is not None and line_b.strip() == "COUNT 1" - ), line_b # B's file survived A's remove + assert line_b is not None and line_b.strip() == "COUNT 1", ( + line_b + ) # B's file survived A's remove pb.wait(timeout=15) diff --git a/tests/cryptpad/custom/test_pad_content_roundtrip.py b/tests/cryptpad/custom/test_pad_content_roundtrip.py index 0b9d1cf..8cba49d 100644 --- a/tests/cryptpad/custom/test_pad_content_roundtrip.py +++ b/tests/cryptpad/custom/test_pad_content_roundtrip.py @@ -150,9 +150,9 @@ def test_cryptpad_pad_content_survives_fresh_session(live_app): # --- session 1: create the pad + write the marker --- ctx1 = browser.new_context(ignore_https_errors=True) page, pad_url = _open_pad(ctx1, f"https://{live_app}/pad/") - assert ( - "#/2/pad/edit/" in pad_url - ), f"CryptPad did not create a fragment-keyed pad URL; got {pad_url!r}" + assert "#/2/pad/edit/" in pad_url, ( + f"CryptPad did not create a fragment-keyed pad URL; got {pad_url!r}" + ) ck = _ckeditor_frame(page, reload_url=pad_url) assert ck is not None, "CKEditor content frame never attached (pad editor not ready)" _dismiss_store_modal(page) @@ -161,9 +161,9 @@ def test_cryptpad_pad_content_survives_fresh_session(live_app): page.wait_for_timeout(1000) body.type(marker, delay=40) page.wait_for_timeout(12000) # let CryptPad encrypt + sync the update to the server - assert ( - marker in ck.locator("body").inner_text() - ), "marker not present in the editor after typing — type did not land" + assert marker in ck.locator("body").inner_text(), ( + "marker not present in the editor after typing — type did not land" + ) ctx1.close() # --- session 2: FRESH context (no shared storage/localStorage) reads the pad back by URL. diff --git a/tests/cryptpad/custom/test_pad_create.py b/tests/cryptpad/custom/test_pad_create.py index 6dd57d0..ecabba1 100644 --- a/tests/cryptpad/custom/test_pad_create.py +++ b/tests/cryptpad/custom/test_pad_create.py @@ -51,9 +51,9 @@ def test_cryptpad_spa_renders_with_no_console_errors(live_app): title = (page.title() or "").lower() body = page.content() blower = body.lower() - assert ( - "cryptpad" in title or "cryptpad" in blower - ), f"CryptPad SPA does not carry brand. title={title!r}, body excerpt: {body[:200]!r}" + assert "cryptpad" in title or "cryptpad" in blower, ( + f"CryptPad SPA does not carry brand. title={title!r}, body excerpt: {body[:200]!r}" + ) # Canonical CryptPad asset references in the rendered DOM canonical = ("/customize/", "/components/", "main.js", "/api/broadcast") diff --git a/tests/cryptpad/test_backup.py b/tests/cryptpad/test_backup.py index acfa7d8..ee7cf5b 100644 --- a/tests/cryptpad/test_backup.py +++ b/tests/cryptpad/test_backup.py @@ -14,6 +14,6 @@ MARKER = "/cryptpad/data/ci-marker.txt" def test_backup_captures_state(live_app): - assert ( - lifecycle.exec_in_app(live_app, ["cat", MARKER]).strip() == "original" - ), "the seeded state was not present at backup time" + assert lifecycle.exec_in_app(live_app, ["cat", MARKER]).strip() == "original", ( + "the seeded state was not present at backup time" + ) diff --git a/tests/cryptpad/test_restore.py b/tests/cryptpad/test_restore.py index 7f8226a..9342a43 100644 --- a/tests/cryptpad/test_restore.py +++ b/tests/cryptpad/test_restore.py @@ -14,6 +14,6 @@ MARKER = "/cryptpad/data/ci-marker.txt" def test_restore_returns_state(live_app): - assert ( - lifecycle.exec_in_app(live_app, ["cat", MARKER]).strip() == "original" - ), "restore did not return the pre-mutation state" + assert lifecycle.exec_in_app(live_app, ["cat", MARKER]).strip() == "original", ( + "restore did not return the pre-mutation state" + ) diff --git a/tests/cryptpad/test_upgrade.py b/tests/cryptpad/test_upgrade.py index c9982da..b236438 100644 --- a/tests/cryptpad/test_upgrade.py +++ b/tests/cryptpad/test_upgrade.py @@ -14,6 +14,6 @@ MARKER = "/cryptpad/data/ci-marker.txt" def test_upgrade_preserves_data(live_app): - assert ( - lifecycle.exec_in_app(live_app, ["cat", MARKER]).strip() == "upgrade-survives" - ), "data did not survive the upgrade" + assert lifecycle.exec_in_app(live_app, ["cat", MARKER]).strip() == "upgrade-survives", ( + "data did not survive the upgrade" + ) diff --git a/tests/custom-html-tiny/custom/test_serves_content.py b/tests/custom-html-tiny/custom/test_serves_content.py index 7eb17e6..cb30917 100644 --- a/tests/custom-html-tiny/custom/test_serves_content.py +++ b/tests/custom-html-tiny/custom/test_serves_content.py @@ -79,9 +79,9 @@ def test_static_file_roundtrip_and_404(live_app): # A random non-existent path must 404 — proves real static-file semantics, distinguishing a # working server from a 200-everything stub or a mis-routed Traefik fallback. miss_status, _ = _get(f"https://{live_app}/ccci-missing-{uuid.uuid4().hex}.txt") - assert ( - miss_status == 404 - ), f"missing path returned {miss_status} (expected 404 — generic 200-returner / mis-route?)" + assert miss_status == 404, ( + f"missing path returned {miss_status} (expected 404 — generic 200-returner / mis-route?)" + ) finally: with contextlib.suppress(OSError): os.remove(path) diff --git a/tests/custom-html/custom/test_content_type_header.py b/tests/custom-html/custom/test_content_type_header.py index dba467b..64c2fd9 100644 --- a/tests/custom-html/custom/test_content_type_header.py +++ b/tests/custom-html/custom/test_content_type_header.py @@ -53,9 +53,9 @@ def test_content_type_html_and_txt(live_app): ct_txt = h_txt.get("content-type", "") # nginx default: "text/html" for .html and "text/plain" for .txt (may include "; charset=utf-8") - assert ct_html.startswith( - "text/html" - ), f"{html_name} Content-Type={ct_html!r}, expected text/html (nginx MIME config broken?)" - assert ct_txt.startswith( - "text/plain" - ), f"{txt_name} Content-Type={ct_txt!r}, expected text/plain (nginx MIME config broken?)" + assert ct_html.startswith("text/html"), ( + f"{html_name} Content-Type={ct_html!r}, expected text/html (nginx MIME config broken?)" + ) + assert ct_txt.startswith("text/plain"), ( + f"{txt_name} Content-Type={ct_txt!r}, expected text/plain (nginx MIME config broken?)" + ) diff --git a/tests/custom-html/test_backup.py b/tests/custom-html/test_backup.py index e645bc1..6098a66 100644 --- a/tests/custom-html/test_backup.py +++ b/tests/custom-html/test_backup.py @@ -16,6 +16,6 @@ MARKER_PATH = "/usr/share/nginx/html/ci-marker.txt" def test_backup_captures_state(live_app): - assert ( - lifecycle.exec_in_app(live_app, ["cat", MARKER_PATH]).strip() == "original" - ), "the seeded state was not present at backup time" + assert lifecycle.exec_in_app(live_app, ["cat", MARKER_PATH]).strip() == "original", ( + "the seeded state was not present at backup time" + ) diff --git a/tests/custom-html/test_restore.py b/tests/custom-html/test_restore.py index e7316dc..7aa952d 100644 --- a/tests/custom-html/test_restore.py +++ b/tests/custom-html/test_restore.py @@ -17,6 +17,6 @@ MARKER_PATH = "/usr/share/nginx/html/ci-marker.txt" def test_restore_returns_state(live_app): restored = lifecycle.exec_in_app(live_app, ["cat", MARKER_PATH]).strip() - assert ( - restored == "original" - ), f"restore did not return the pre-mutation (backed-up) state: got {restored!r}" + assert restored == "original", ( + f"restore did not return the pre-mutation (backed-up) state: got {restored!r}" + ) diff --git a/tests/custom-html/test_upgrade.py b/tests/custom-html/test_upgrade.py index 01be9bf..2fdd168 100644 --- a/tests/custom-html/test_upgrade.py +++ b/tests/custom-html/test_upgrade.py @@ -16,6 +16,6 @@ MARKER_PATH = "/usr/share/nginx/html/ci-marker.txt" def test_upgrade_preserves_data(live_app): # the marker seeded by ops.pre_upgrade (before the harness upgraded) is still served - assert ( - lifecycle.http_fetch(live_app, "/ci-marker.txt")[1].strip() == "upgrade-survives" - ), "data did not survive the upgrade" + assert lifecycle.http_fetch(live_app, "/ci-marker.txt")[1].strip() == "upgrade-survives", ( + "data did not survive the upgrade" + ) diff --git a/tests/discourse/custom/_discourse.py b/tests/discourse/custom/_discourse.py index 81494e2..954b8e7 100644 --- a/tests/discourse/custom/_discourse.py +++ b/tests/discourse/custom/_discourse.py @@ -81,9 +81,9 @@ def mint_admin(domain: str) -> tuple[str, str]: key = line.split("=", 1)[1].strip() elif line.startswith("CCCI_API_USER="): user = line.split("=", 1)[1].strip() - assert ( - key and user - ), f"could not bootstrap discourse admin/API key; rails output tail:\n{out[-1000:]}" + assert key and user, ( + f"could not bootstrap discourse admin/API key; rails output tail:\n{out[-1000:]}" + ) return key, user diff --git a/tests/discourse/custom/test_create_topic.py b/tests/discourse/custom/test_create_topic.py index 4b078a5..95f33b4 100644 --- a/tests/discourse/custom/test_create_topic.py +++ b/tests/discourse/custom/test_create_topic.py @@ -48,23 +48,23 @@ def test_create_topic_roundtrip(live_app): headers=hdrs, timeout=60, ) - assert status in (200, 201) and isinstance( - body, dict - ), f"create topic failed: HTTP {status}, body={body!r}" + assert status in (200, 201) and isinstance(body, dict), ( + f"create topic failed: HTTP {status}, body={body!r}" + ) topic_id = body.get("topic_id") assert topic_id, f"create topic returned no topic_id: {body!r}" # 4) Read the topic back and assert title + first-post body round-trip. status, got = harness_http.http_get(f"{base}/t/{topic_id}.json", headers=hdrs, timeout=30) - assert status == 200 and isinstance( - got, dict - ), f"read topic failed: HTTP {status}, body={got!r}" - assert ( - got.get("title") == title - ), f"topic title did not round-trip: sent {title!r}, got {got.get('title')!r}" + assert status == 200 and isinstance(got, dict), ( + f"read topic failed: HTTP {status}, body={got!r}" + ) + assert got.get("title") == title, ( + f"topic title did not round-trip: sent {title!r}, got {got.get('title')!r}" + ) posts = (got.get("post_stream") or {}).get("posts") or [] assert posts, f"topic has no posts on read-back: {got!r}" first_cooked = posts[0].get("cooked", "") - assert ( - marker in first_cooked - ), f"topic body did not round-trip: marker {marker!r} not in first post {first_cooked!r}" + assert marker in first_cooked, ( + f"topic body did not round-trip: marker {marker!r} not in first post {first_cooked!r}" + ) diff --git a/tests/discourse/custom/test_site_basic.py b/tests/discourse/custom/test_site_basic.py index 77414c2..fd8793d 100644 --- a/tests/discourse/custom/test_site_basic.py +++ b/tests/discourse/custom/test_site_basic.py @@ -20,12 +20,12 @@ def test_site_json_has_discourse_config(live_app): status, body = harness_http.retry_http_get( f"https://{live_app}/site.json", expect_status=200, max_wait=120, interval=5 ) - assert status == 200 and isinstance( - body, dict - ), f"GET /site.json failed: HTTP {status}, body type={type(body).__name__}" + assert status == 200 and isinstance(body, dict), ( + f"GET /site.json failed: HTTP {status}, body type={type(body).__name__}" + ) # /site.json carries Discourse-specific structure — `categories` (a list) and `groups` are always # present in a booted Discourse. A non-Discourse 200 (placeholder page) would not parse to this. assert "categories" in body, f"/site.json missing 'categories' key: keys={list(body)[:20]}" - assert isinstance( - body["categories"], list - ), f"/site.json 'categories' not a list: {type(body['categories']).__name__}" + assert isinstance(body["categories"], list), ( + f"/site.json 'categories' not a list: {type(body['categories']).__name__}" + ) diff --git a/tests/discourse/ops.py b/tests/discourse/ops.py index 35087fa..b4af843 100644 --- a/tests/discourse/ops.py +++ b/tests/discourse/ops.py @@ -14,9 +14,7 @@ from harness import lifecycle # noqa: E402 def _psql(domain, sql): - cmd = ( - "PGPASSWORD=$(cat /run/secrets/db_password) " f'psql -U discourse -d discourse -tAc "{sql}"' - ) + cmd = f'PGPASSWORD=$(cat /run/secrets/db_password) psql -U discourse -d discourse -tAc "{sql}"' return lifecycle.exec_in_app(domain, ["sh", "-c", cmd], service="db").strip() diff --git a/tests/discourse/test_backup.py b/tests/discourse/test_backup.py index 003dad3..5911311 100644 --- a/tests/discourse/test_backup.py +++ b/tests/discourse/test_backup.py @@ -13,13 +13,11 @@ from harness import lifecycle # noqa: E402 def _psql(domain, sql): - cmd = ( - "PGPASSWORD=$(cat /run/secrets/db_password) " f'psql -U discourse -d discourse -tAc "{sql}"' - ) + cmd = f'PGPASSWORD=$(cat /run/secrets/db_password) psql -U discourse -d discourse -tAc "{sql}"' return lifecycle.exec_in_app(domain, ["sh", "-c", cmd], service="db").strip() def test_backup_captures_state(live_app): - assert ( - _psql(live_app, "SELECT v FROM ci_marker;") == "original" - ), "the seeded discourse postgres state was not present at backup time" + assert _psql(live_app, "SELECT v FROM ci_marker;") == "original", ( + "the seeded discourse postgres state was not present at backup time" + ) diff --git a/tests/discourse/test_restore.py b/tests/discourse/test_restore.py index f93b9e7..78e3135 100644 --- a/tests/discourse/test_restore.py +++ b/tests/discourse/test_restore.py @@ -13,13 +13,11 @@ from harness import lifecycle # noqa: E402 def _psql(domain, sql): - cmd = ( - "PGPASSWORD=$(cat /run/secrets/db_password) " f'psql -U discourse -d discourse -tAc "{sql}"' - ) + cmd = f'PGPASSWORD=$(cat /run/secrets/db_password) psql -U discourse -d discourse -tAc "{sql}"' return lifecycle.exec_in_app(domain, ["sh", "-c", cmd], service="db").strip() def test_restore_returns_state(live_app): - assert ( - _psql(live_app, "SELECT v FROM ci_marker;") == "original" - ), "restore did not return the pre-mutation discourse postgres state (data-integrity failure)" + assert _psql(live_app, "SELECT v FROM ci_marker;") == "original", ( + "restore did not return the pre-mutation discourse postgres state (data-integrity failure)" + ) diff --git a/tests/ghost/custom/test_admin_redirect.py b/tests/ghost/custom/test_admin_redirect.py index 5403546..f675843 100644 --- a/tests/ghost/custom/test_admin_redirect.py +++ b/tests/ghost/custom/test_admin_redirect.py @@ -62,6 +62,6 @@ def test_ghost_admin_route_is_wired(live_app): assert status in (200, 302), f"unexpected status: {status}" if status == 200: # The admin SPA references /ghost-assets/ or contains "ghost" in title/body - assert ( - "ghost" in body.lower() - ), f"GET {url} 200 but body has no Ghost markers: {body[:200]!r}" + assert "ghost" in body.lower(), ( + f"GET {url} 200 but body has no Ghost markers: {body[:200]!r}" + ) diff --git a/tests/ghost/custom/test_content_api.py b/tests/ghost/custom/test_content_api.py index 3c8282a..32feaab 100644 --- a/tests/ghost/custom/test_content_api.py +++ b/tests/ghost/custom/test_content_api.py @@ -35,10 +35,10 @@ def test_content_api_settings_endpoint(live_app): assert body is not None, f"GET {url} returned non-JSON body" # On success: {"settings": {...}}. On error: {"errors": [...]}. Either shape is valid. if status == 200: - assert ( - isinstance(body, dict) and "settings" in body - ), f"200 response missing 'settings' envelope: {body!r}" + assert isinstance(body, dict) and "settings" in body, ( + f"200 response missing 'settings' envelope: {body!r}" + ) else: - assert isinstance(body, dict) and ( - "errors" in body or "message" in body or body - ), f"error response not a proper Ghost error envelope: {body!r}" + assert isinstance(body, dict) and ("errors" in body or "message" in body or body), ( + f"error response not a proper Ghost error envelope: {body!r}" + ) diff --git a/tests/ghost/custom/test_post_roundtrip.py b/tests/ghost/custom/test_post_roundtrip.py index f61f84d..ccb1916 100644 --- a/tests/ghost/custom/test_post_roundtrip.py +++ b/tests/ghost/custom/test_post_roundtrip.py @@ -43,17 +43,17 @@ def test_create_post_roundtrip(live_app): title = f"ccci-marker-{uniq}" marker = f"ccci-body-marker-{uniq}-roundtrip" created = admin.create_post(title, f"

{marker}

") - assert ( - created.get("title") == title - ), f"created post title mismatch: sent {title!r}, got {created.get('title')!r}" + assert created.get("title") == title, ( + f"created post title mismatch: sent {title!r}, got {created.get('title')!r}" + ) # 4) Read it back by id and assert the post survived the round-trip (title always returned; # html returned because we requested ?formats=html). got = admin.get_post(created["id"]) - assert ( - got.get("title") == title - ), f"post title did not round-trip: sent {title!r}, got {got.get('title')!r}" + assert got.get("title") == title, ( + f"post title did not round-trip: sent {title!r}, got {got.get('title')!r}" + ) html = got.get("html") or "" - assert ( - marker in html - ), f"post body did not round-trip: marker {marker!r} not in read-back html {html!r}" + assert marker in html, ( + f"post body did not round-trip: marker {marker!r} not in read-back html {html!r}" + ) diff --git a/tests/ghost/ops.py b/tests/ghost/ops.py index 74ec035..92f6dff 100644 --- a/tests/ghost/ops.py +++ b/tests/ghost/ops.py @@ -22,7 +22,7 @@ from harness import lifecycle # noqa: E402 def _mysql(domain, sql): - cmd = 'MYSQL_PWD="$(cat /run/secrets/db_password)" ' f'mysql -u root -N -s ghost -e "{sql}"' + cmd = f'MYSQL_PWD="$(cat /run/secrets/db_password)" mysql -u root -N -s ghost -e "{sql}"' return lifecycle.exec_in_app(domain, ["sh", "-c", cmd], service="db").strip() diff --git a/tests/ghost/test_backup.py b/tests/ghost/test_backup.py index 4f1a5ea..aef72ad 100644 --- a/tests/ghost/test_backup.py +++ b/tests/ghost/test_backup.py @@ -15,11 +15,11 @@ from harness import lifecycle # noqa: E402 def _mysql(domain, sql): - cmd = 'MYSQL_PWD="$(cat /run/secrets/db_password)" ' f'mysql -u root -N -s ghost -e "{sql}"' + cmd = f'MYSQL_PWD="$(cat /run/secrets/db_password)" mysql -u root -N -s ghost -e "{sql}"' return lifecycle.exec_in_app(domain, ["sh", "-c", cmd], service="db").strip() def test_backup_captures_state(live_app): - assert ( - _mysql(live_app, "SELECT v FROM ci_marker;") == "original" - ), "the seeded ghost MySQL marker was not present at backup time" + assert _mysql(live_app, "SELECT v FROM ci_marker;") == "original", ( + "the seeded ghost MySQL marker was not present at backup time" + ) diff --git a/tests/ghost/test_restore.py b/tests/ghost/test_restore.py index 2e0fbc3..e36b399 100644 --- a/tests/ghost/test_restore.py +++ b/tests/ghost/test_restore.py @@ -22,7 +22,7 @@ from harness import lifecycle # noqa: E402 def _mysql(domain, sql): - cmd = 'MYSQL_PWD="$(cat /run/secrets/db_password)" ' f'mysql -u root -N -s ghost -e "{sql}"' + cmd = f'MYSQL_PWD="$(cat /run/secrets/db_password)" mysql -u root -N -s ghost -e "{sql}"' return lifecycle.exec_in_app(domain, ["sh", "-c", cmd], service="db").strip() diff --git a/tests/ghost/test_upgrade.py b/tests/ghost/test_upgrade.py index efebbdb..df97edc 100644 --- a/tests/ghost/test_upgrade.py +++ b/tests/ghost/test_upgrade.py @@ -14,11 +14,11 @@ from harness import lifecycle # noqa: E402 def _mysql(domain, sql): - cmd = 'MYSQL_PWD="$(cat /run/secrets/db_password)" ' f'mysql -u root -N -s ghost -e "{sql}"' + cmd = f'MYSQL_PWD="$(cat /run/secrets/db_password)" mysql -u root -N -s ghost -e "{sql}"' return lifecycle.exec_in_app(domain, ["sh", "-c", cmd], service="db").strip() def test_upgrade_preserves_state(live_app): - assert ( - _mysql(live_app, "SELECT v FROM ci_marker;") == "upgrade-survives" - ), "the seeded ghost MySQL marker did not survive the upgrade redeploy (data loss on upgrade)" + assert _mysql(live_app, "SELECT v FROM ci_marker;") == "upgrade-survives", ( + "the seeded ghost MySQL marker did not survive the upgrade redeploy (data loss on upgrade)" + ) diff --git a/tests/gitea/custom/test_lfs_roundtrip.py b/tests/gitea/custom/test_lfs_roundtrip.py index 5f3aa24..f118066 100644 --- a/tests/gitea/custom/test_lfs_roundtrip.py +++ b/tests/gitea/custom/test_lfs_roundtrip.py @@ -145,9 +145,9 @@ def test_lfs_roundtrip(live_app): text=True, env={**os.environ, **git_env}, ) - assert ( - "testblob.bin" in lfs_ls.stdout - ), f"testblob.bin not in git-lfs ls-files: {lfs_ls.stdout}" + assert "testblob.bin" in lfs_ls.stdout, ( + f"testblob.bin not in git-lfs ls-files: {lfs_ls.stdout}" + ) # 6. Download in a FRESH clone (proves the LFS server stores and serves the object) fresh_dir = tempfile.mkdtemp(prefix="ccci-gitea-lfs-dl-") @@ -158,9 +158,9 @@ def test_lfs_roundtrip(live_app): with open(fetched_path, "rb") as f: fetched = f.read() fetched_sha256 = hashlib.sha256(fetched).hexdigest() - assert ( - fetched_sha256 == expected_sha256 - ), f"LFS round-trip OID mismatch: expected {expected_oid}, got sha256:{fetched_sha256}" + assert fetched_sha256 == expected_sha256, ( + f"LFS round-trip OID mismatch: expected {expected_oid}, got sha256:{fetched_sha256}" + ) finally: shutil.rmtree(fresh_dir, ignore_errors=True) @@ -171,9 +171,9 @@ def test_lfs_roundtrip(live_app): ["sh", "-c", "grep -E '^LFS_JWT_SECRET' /etc/gitea/app.ini || echo NOT_FOUND"], timeout=30, ).strip() - assert ( - current_jwt and "NOT_FOUND" not in current_jwt - ), "Could not read LFS_JWT_SECRET from /etc/gitea/app.ini before restart" + assert current_jwt and "NOT_FOUND" not in current_jwt, ( + "Could not read LFS_JWT_SECRET from /etc/gitea/app.ini before restart" + ) # Restart the gitea container lifecycle.exec_in_app(live_app, ["true"], timeout=5) # no-op to confirm exec works @@ -213,9 +213,9 @@ def test_lfs_roundtrip(live_app): assert os.path.exists(pr_blob), "testblob.bin not fetched in post-restart clone" with open(pr_blob, "rb") as f: pr_data = f.read() - assert ( - hashlib.sha256(pr_data).hexdigest() == expected_sha256 - ), "LFS object corrupted after restart — JWT secret may have changed" + assert hashlib.sha256(pr_data).hexdigest() == expected_sha256, ( + "LFS object corrupted after restart — JWT secret may have changed" + ) finally: shutil.rmtree(post_restart_dir, ignore_errors=True) diff --git a/tests/gitea/ops.py b/tests/gitea/ops.py index c65f915..db38b6f 100644 --- a/tests/gitea/ops.py +++ b/tests/gitea/ops.py @@ -220,7 +220,7 @@ def pre_restore(ctx): generic.assert_serving(ctx.domain, ctx.meta) ok = _delete_marker_repo(ctx.domain, user, password) assert ok, f"pre_restore: could not delete {_MARKER_REPO} repo on {ctx.domain}" - assert not marker_repo_exists( - ctx.domain, user, password - ), f"pre_restore: {_MARKER_REPO} still present after delete — divergence did not take" + assert not marker_repo_exists(ctx.domain, user, password), ( + f"pre_restore: {_MARKER_REPO} still present after delete — divergence did not take" + ) print(f" gitea ops: {_MARKER_REPO!r} deleted (diverged from backup state)", flush=True) diff --git a/tests/gitea/test_backup.py b/tests/gitea/test_backup.py index 57b2f16..229ff72 100644 --- a/tests/gitea/test_backup.py +++ b/tests/gitea/test_backup.py @@ -22,6 +22,6 @@ def test_backup_captures_marker_repo(live_app, meta): # backupbot cycles the gitea container during backup — wait for it to be back up. generic.assert_serving(live_app, meta) user, password = admin_creds(live_app) - assert marker_repo_exists( - live_app, user, password - ), f"{live_app}: ci-marker repo is not present at backup time (backup would capture empty state)" + assert marker_repo_exists(live_app, user, password), ( + f"{live_app}: ci-marker repo is not present at backup time (backup would capture empty state)" + ) diff --git a/tests/gitea/test_install.py b/tests/gitea/test_install.py index 296ccf5..3fa6c45 100644 --- a/tests/gitea/test_install.py +++ b/tests/gitea/test_install.py @@ -65,8 +65,8 @@ def test_install_gitea(live_app, meta): ) page.wait_for_selector("input#user_name", timeout=20_000) content = page.content() - assert ( - "gitea" in content.lower() or "sign in" in content.lower() - ), "Sign-in page did not render expected gitea content" + assert "gitea" in content.lower() or "sign in" in content.lower(), ( + "Sign-in page did not render expected gitea content" + ) finally: browser.close() diff --git a/tests/gitea/test_upgrade.py b/tests/gitea/test_upgrade.py index 8f2f46e..5a7589c 100644 --- a/tests/gitea/test_upgrade.py +++ b/tests/gitea/test_upgrade.py @@ -20,6 +20,6 @@ def test_upgrade_preserves_marker_repo(live_app, meta): """The ci-marker repo survived the upgrade to the PR head (data continuity).""" generic.assert_serving(live_app, meta) user, password = admin_creds(live_app) - assert marker_repo_exists( - live_app, user, password - ), f"{live_app}: ci-marker repo did not survive the upgrade (sqlite3 data lost)" + assert marker_repo_exists(live_app, user, password), ( + f"{live_app}: ci-marker repo did not survive the upgrade (sqlite3 data lost)" + ) diff --git a/tests/immich/custom/test_asset_processing.py b/tests/immich/custom/test_asset_processing.py index d637308..b5df995 100644 --- a/tests/immich/custom/test_asset_processing.py +++ b/tests/immich/custom/test_asset_processing.py @@ -111,13 +111,13 @@ def test_immich_processes_uploaded_asset_metadata_and_statistics(live_app): if exif and exif.get("exifImageWidth"): break time.sleep(5) - assert ( - exif and exif.get("exifImageWidth") == 1 and exif.get("exifImageHeight") == 1 - ), f"immich metadata-extraction did not populate the 1x1 PNG dimensions in exifInfo: {exif!r}" + assert exif and exif.get("exifImageWidth") == 1 and exif.get("exifImageHeight") == 1, ( + f"immich metadata-extraction did not populate the 1x1 PNG dimensions in exifInfo: {exif!r}" + ) # the asset is catalogued into the owner's library statistics (list-back in aggregate) sst, stats = harness_http.http_request("GET", f"{base}/api/assets/statistics", headers=auth) assert sst == 200 and isinstance(stats, dict), f"statistics HTTP {sst}: {stats!r}" - assert ( - stats.get("images", 0) >= 1 and stats.get("total", 0) >= 1 - ), f"uploaded asset not reflected in library statistics: {stats!r}" + assert stats.get("images", 0) >= 1 and stats.get("total", 0) >= 1, ( + f"uploaded asset not reflected in library statistics: {stats!r}" + ) diff --git a/tests/immich/custom/test_asset_upload.py b/tests/immich/custom/test_asset_upload.py index 0339401..05b7131 100644 --- a/tests/immich/custom/test_asset_upload.py +++ b/tests/immich/custom/test_asset_upload.py @@ -121,6 +121,6 @@ def test_immich_upload_asset_readback_and_thumbnail(live_app): if thumb == 200: break time.sleep(5) - assert ( - thumb == 200 - ), f"immich did not generate a thumbnail/derivative for the uploaded asset (last HTTP {thumb})" + assert thumb == 200, ( + f"immich did not generate a thumbnail/derivative for the uploaded asset (last HTTP {thumb})" + ) diff --git a/tests/immich/test_backup.py b/tests/immich/test_backup.py index 1dc8756..d66a6bc 100644 --- a/tests/immich/test_backup.py +++ b/tests/immich/test_backup.py @@ -14,6 +14,6 @@ def _psql(domain, sql): def test_backup_captures_state(live_app): - assert ( - _psql(live_app, "SELECT v FROM ci_marker;") == "original" - ), "seeded postgres state not present at backup time" + assert _psql(live_app, "SELECT v FROM ci_marker;") == "original", ( + "seeded postgres state not present at backup time" + ) diff --git a/tests/immich/test_restore.py b/tests/immich/test_restore.py index 8bba38e..fcb752c 100644 --- a/tests/immich/test_restore.py +++ b/tests/immich/test_restore.py @@ -14,6 +14,6 @@ def _psql(domain, sql): def test_restore_returns_state(live_app): - assert ( - _psql(live_app, "SELECT v FROM ci_marker;") == "original" - ), "restore did not return the pre-mutation postgres state" + assert _psql(live_app, "SELECT v FROM ci_marker;") == "original", ( + "restore did not return the pre-mutation postgres state" + ) diff --git a/tests/immich/test_upgrade.py b/tests/immich/test_upgrade.py index ece6657..f259127 100644 --- a/tests/immich/test_upgrade.py +++ b/tests/immich/test_upgrade.py @@ -14,6 +14,6 @@ def _psql(domain, sql): def test_upgrade_preserves_data(live_app): - assert ( - _psql(live_app, "SELECT v FROM ci_marker;") == "upgrade-survives" - ), "postgres data did not survive the upgrade" + assert _psql(live_app, "SELECT v FROM ci_marker;") == "upgrade-survives", ( + "postgres data did not survive the upgrade" + ) diff --git a/tests/keycloak/custom/test_create_client_and_use.py b/tests/keycloak/custom/test_create_client_and_use.py index 62771f1..51b1c44 100644 --- a/tests/keycloak/custom/test_create_client_and_use.py +++ b/tests/keycloak/custom/test_create_client_and_use.py @@ -144,25 +144,25 @@ def test_create_confidential_client_and_obtain_token(live_app): # Use the client to obtain its own token (client_credentials grant) tok_status, tok_resp = _client_credentials_token(live_app, client_id, client_secret) - assert ( - tok_status == 200 - ), f"client_credentials token returned HTTP {tok_status}: {tok_resp!r}" + assert tok_status == 200, ( + f"client_credentials token returned HTTP {tok_status}: {tok_resp!r}" + ) access_token = tok_resp.get("access_token") if isinstance(tok_resp, dict) else None - assert ( - isinstance(access_token, str) and access_token.count(".") == 2 - ), f"client_credentials access_token not a JWT: {access_token!r}" + assert isinstance(access_token, str) and access_token.count(".") == 2, ( + f"client_credentials access_token not a JWT: {access_token!r}" + ) # Decode the JWT payload; assert azp matches the new client payload = json.loads(_b64url_decode(access_token.split(".")[1])) - assert ( - payload.get("azp") == client_id - ), f"client_credentials JWT azp={payload.get('azp')!r} != client_id={client_id!r}" + assert payload.get("azp") == client_id, ( + f"client_credentials JWT azp={payload.get('azp')!r} != client_id={client_id!r}" + ) # Service-account token does NOT carry a session-scoped user (azp + clientId differ from # admin-cli token). The presence of azp + iss == per-run-domain proves the issuance flow. expected_iss = f"https://{live_app}/realms/master" - assert ( - payload.get("iss") == expected_iss - ), f"JWT iss={payload.get('iss')!r} != {expected_iss!r}" + assert payload.get("iss") == expected_iss, ( + f"JWT iss={payload.get('iss')!r} != {expected_iss!r}" + ) finally: # Idempotent cleanup if cleanup_id: diff --git a/tests/keycloak/custom/test_password_grant_token.py b/tests/keycloak/custom/test_password_grant_token.py index 44b6d17..f160beb 100644 --- a/tests/keycloak/custom/test_password_grant_token.py +++ b/tests/keycloak/custom/test_password_grant_token.py @@ -43,17 +43,17 @@ def test_password_grant_issues_valid_jwt(live_app): token = kc_admin.admin_token(live_app, password) # Shape: a JWT is exactly 3 base64url segments - assert ( - isinstance(token, str) and token.count(".") == 2 - ), f"access_token does not look like a JWT (no 3 segments): len={len(token) if token else 0}" + assert isinstance(token, str) and token.count(".") == 2, ( + f"access_token does not look like a JWT (no 3 segments): len={len(token) if token else 0}" + ) payload = _decode_jwt_payload(token) # iss = the issuer URL, must be the per-run domain's /realms/master endpoint expected_iss = f"https://{live_app}/realms/master" - assert ( - payload.get("iss") == expected_iss - ), f"JWT iss claim {payload.get('iss')!r} != {expected_iss!r}" + assert payload.get("iss") == expected_iss, ( + f"JWT iss claim {payload.get('iss')!r} != {expected_iss!r}" + ) # azp = authorized party (which client requested this token) assert payload.get("azp") == "admin-cli", f"JWT azp claim {payload.get('azp')!r} != 'admin-cli'" @@ -68,6 +68,6 @@ def test_password_grant_issues_valid_jwt(live_app): # iat (issued at) is also a standard claim iat = payload.get("iat") - assert ( - isinstance(iat, int) and iat <= time.time() + 60 - ), f"JWT iat {iat!r} not a reasonable past timestamp" + assert isinstance(iat, int) and iat <= time.time() + 60, ( + f"JWT iat {iat!r} not a reasonable past timestamp" + ) diff --git a/tests/lasuite-docs/custom/test_oidc_with_keycloak.py b/tests/lasuite-docs/custom/test_oidc_with_keycloak.py index bd865de..eed2ac2 100644 --- a/tests/lasuite-docs/custom/test_oidc_with_keycloak.py +++ b/tests/lasuite-docs/custom/test_oidc_with_keycloak.py @@ -42,9 +42,9 @@ def test_oidc_password_grant_against_dep_keycloak(live_app, deps): # Sanity-check the creds shape — orchestrator-written assert kc["domain"] # WC1: realm is per-run namespaced "-<6hex>" so concurrent dependents never collide. - assert re.fullmatch( - r"lasuite-docs-[0-9a-f]{6}", kc["realm"] - ), f"realm {kc['realm']!r} not the per-run namespaced form lasuite-docs-<6hex>" + assert re.fullmatch(r"lasuite-docs-[0-9a-f]{6}", kc["realm"]), ( + f"realm {kc['realm']!r} not the per-run namespaced form lasuite-docs-<6hex>" + ) assert kc["client_id"] == "lasuite-docs" assert isinstance(kc["client_secret"], str) and len(kc["client_secret"]) >= 16 assert isinstance(kc["password"], str) and len(kc["password"]) >= 16 @@ -77,11 +77,11 @@ def test_oidc_password_grant_against_dep_keycloak(live_app, deps): assert isinstance(token, str) and token.count(".") == 2, f"access_token is not a JWT: {token!r}" payload = json.loads(_b64url_decode(token.split(".")[1])) assert payload.get("iss") == expected_iss, f"JWT iss={payload.get('iss')!r} != {expected_iss!r}" - assert ( - payload.get("azp") == kc["client_id"] - ), f"JWT azp={payload.get('azp')!r} != {kc['client_id']!r}" + assert payload.get("azp") == kc["client_id"], ( + f"JWT azp={payload.get('azp')!r} != {kc['client_id']!r}" + ) assert payload.get("typ") == "Bearer", f"JWT typ={payload.get('typ')!r} != 'Bearer'" exp = payload.get("exp") - assert ( - isinstance(exp, int) and exp > time.time() - ), f"JWT exp={exp!r} not a future timestamp (now={time.time():.0f})" + assert isinstance(exp, int) and exp > time.time(), ( + f"JWT exp={exp!r} not a future timestamp (now={time.time():.0f})" + ) diff --git a/tests/lasuite-docs/test_backup.py b/tests/lasuite-docs/test_backup.py index d4be23c..5a0e47f 100644 --- a/tests/lasuite-docs/test_backup.py +++ b/tests/lasuite-docs/test_backup.py @@ -18,6 +18,6 @@ def _psql(domain, sql): def test_backup_captures_state(live_app): - assert ( - _psql(live_app, "SELECT v FROM ci_marker;") == "original" - ), "the seeded postgres state was not present at backup time" + assert _psql(live_app, "SELECT v FROM ci_marker;") == "original", ( + "the seeded postgres state was not present at backup time" + ) diff --git a/tests/lasuite-docs/test_restore.py b/tests/lasuite-docs/test_restore.py index 91aeb09..90123aa 100644 --- a/tests/lasuite-docs/test_restore.py +++ b/tests/lasuite-docs/test_restore.py @@ -17,6 +17,6 @@ def _psql(domain, sql): def test_restore_returns_state(live_app): - assert ( - _psql(live_app, "SELECT v FROM ci_marker;") == "original" - ), "restore did not return the pre-mutation postgres state" + assert _psql(live_app, "SELECT v FROM ci_marker;") == "original", ( + "restore did not return the pre-mutation postgres state" + ) diff --git a/tests/lasuite-docs/test_upgrade.py b/tests/lasuite-docs/test_upgrade.py index 6cb3b40..fc01b99 100644 --- a/tests/lasuite-docs/test_upgrade.py +++ b/tests/lasuite-docs/test_upgrade.py @@ -17,6 +17,6 @@ def _psql(domain, sql): def test_upgrade_preserves_data(live_app): - assert ( - _psql(live_app, "SELECT v FROM ci_marker;") == "upgrade-survives" - ), "postgres data did not survive the upgrade" + assert _psql(live_app, "SELECT v FROM ci_marker;") == "upgrade-survives", ( + "postgres data did not survive the upgrade" + ) diff --git a/tests/lasuite-drive/custom/test_minio_storage.py b/tests/lasuite-drive/custom/test_minio_storage.py index b11d22d..345579c 100644 --- a/tests/lasuite-drive/custom/test_minio_storage.py +++ b/tests/lasuite-drive/custom/test_minio_storage.py @@ -56,6 +56,6 @@ def test_minio_bucket_present_and_object_roundtrip(live_app): # The object was listed (its key appears) and its content round-tripped intact. assert f"{marker}.txt" in out, f"uploaded object not listed in bucket: {out!r}" - assert ( - f"READBACK:{marker}" in out - ), f"object content did not round-trip through MinIO; got: {out!r}" + assert f"READBACK:{marker}" in out, ( + f"object content did not round-trip through MinIO; got: {out!r}" + ) diff --git a/tests/lasuite-drive/custom/test_oidc_with_keycloak.py b/tests/lasuite-drive/custom/test_oidc_with_keycloak.py index 4364026..062a187 100644 --- a/tests/lasuite-drive/custom/test_oidc_with_keycloak.py +++ b/tests/lasuite-drive/custom/test_oidc_with_keycloak.py @@ -46,9 +46,9 @@ def test_oidc_password_grant_against_dep_keycloak(live_app, deps): # Creds shape. WC1: realm is per-run namespaced "-<6hex>"; client_id stays the parent. assert kc["domain"] - assert re.fullmatch( - r"lasuite-drive-[0-9a-f]{6}", kc["realm"] - ), f"realm {kc['realm']!r} not the per-run namespaced form lasuite-drive-<6hex>" + assert re.fullmatch(r"lasuite-drive-[0-9a-f]{6}", kc["realm"]), ( + f"realm {kc['realm']!r} not the per-run namespaced form lasuite-drive-<6hex>" + ) assert kc["client_id"] == "lasuite-drive" assert isinstance(kc["client_secret"], str) and len(kc["client_secret"]) >= 16 assert isinstance(kc["password"], str) and len(kc["password"]) >= 16 @@ -80,11 +80,11 @@ def test_oidc_password_grant_against_dep_keycloak(live_app, deps): assert isinstance(token, str) and token.count(".") == 2, f"access_token is not a JWT: {token!r}" payload = json.loads(_b64url_decode(token.split(".")[1])) assert payload.get("iss") == expected_iss, f"JWT iss={payload.get('iss')!r} != {expected_iss!r}" - assert ( - payload.get("azp") == kc["client_id"] - ), f"JWT azp={payload.get('azp')!r} != {kc['client_id']!r}" + assert payload.get("azp") == kc["client_id"], ( + f"JWT azp={payload.get('azp')!r} != {kc['client_id']!r}" + ) assert payload.get("typ") == "Bearer", f"JWT typ={payload.get('typ')!r} != 'Bearer'" exp = payload.get("exp") - assert ( - isinstance(exp, int) and exp > time.time() - ), f"JWT exp={exp!r} not a future timestamp (now={time.time():.0f})" + assert isinstance(exp, int) and exp > time.time(), ( + f"JWT exp={exp!r} not a future timestamp (now={time.time():.0f})" + ) diff --git a/tests/lasuite-drive/test_backup.py b/tests/lasuite-drive/test_backup.py index 932729f..ba3d7f4 100644 --- a/tests/lasuite-drive/test_backup.py +++ b/tests/lasuite-drive/test_backup.py @@ -18,6 +18,6 @@ def _psql(domain, sql): def test_backup_captures_state(live_app): - assert ( - _psql(live_app, "SELECT v FROM ci_marker;") == "original" - ), "the seeded postgres state was not present at backup time" + assert _psql(live_app, "SELECT v FROM ci_marker;") == "original", ( + "the seeded postgres state was not present at backup time" + ) diff --git a/tests/lasuite-drive/test_restore.py b/tests/lasuite-drive/test_restore.py index 786886f..302f75e 100644 --- a/tests/lasuite-drive/test_restore.py +++ b/tests/lasuite-drive/test_restore.py @@ -17,6 +17,6 @@ def _psql(domain, sql): def test_restore_returns_state(live_app): - assert ( - _psql(live_app, "SELECT v FROM ci_marker;") == "original" - ), "restore did not return the pre-mutation postgres state" + assert _psql(live_app, "SELECT v FROM ci_marker;") == "original", ( + "restore did not return the pre-mutation postgres state" + ) diff --git a/tests/lasuite-drive/test_upgrade.py b/tests/lasuite-drive/test_upgrade.py index 68571a9..3cacc5a 100644 --- a/tests/lasuite-drive/test_upgrade.py +++ b/tests/lasuite-drive/test_upgrade.py @@ -17,6 +17,6 @@ def _psql(domain, sql): def test_upgrade_preserves_data(live_app): - assert ( - _psql(live_app, "SELECT v FROM ci_marker;") == "upgrade-survives" - ), "postgres data did not survive the upgrade" + assert _psql(live_app, "SELECT v FROM ci_marker;") == "upgrade-survives", ( + "postgres data did not survive the upgrade" + ) diff --git a/tests/lasuite-meet/custom/test_oidc_with_keycloak.py b/tests/lasuite-meet/custom/test_oidc_with_keycloak.py index 27e741b..5314b0d 100644 --- a/tests/lasuite-meet/custom/test_oidc_with_keycloak.py +++ b/tests/lasuite-meet/custom/test_oidc_with_keycloak.py @@ -46,9 +46,9 @@ def test_oidc_password_grant_against_dep_keycloak(live_app, deps): # Creds shape. WC1: realm is per-run namespaced "-<6hex>"; client_id stays the parent. assert kc["domain"] - assert re.fullmatch( - r"lasuite-meet-[0-9a-f]{6}", kc["realm"] - ), f"realm {kc['realm']!r} not the per-run namespaced form lasuite-meet-<6hex>" + assert re.fullmatch(r"lasuite-meet-[0-9a-f]{6}", kc["realm"]), ( + f"realm {kc['realm']!r} not the per-run namespaced form lasuite-meet-<6hex>" + ) assert kc["client_id"] == "lasuite-meet" assert isinstance(kc["client_secret"], str) and len(kc["client_secret"]) >= 16 assert isinstance(kc["password"], str) and len(kc["password"]) >= 16 @@ -80,11 +80,11 @@ def test_oidc_password_grant_against_dep_keycloak(live_app, deps): assert isinstance(token, str) and token.count(".") == 2, f"access_token is not a JWT: {token!r}" payload = json.loads(_b64url_decode(token.split(".")[1])) assert payload.get("iss") == expected_iss, f"JWT iss={payload.get('iss')!r} != {expected_iss!r}" - assert ( - payload.get("azp") == kc["client_id"] - ), f"JWT azp={payload.get('azp')!r} != {kc['client_id']!r}" + assert payload.get("azp") == kc["client_id"], ( + f"JWT azp={payload.get('azp')!r} != {kc['client_id']!r}" + ) assert payload.get("typ") == "Bearer", f"JWT typ={payload.get('typ')!r} != 'Bearer'" exp = payload.get("exp") - assert ( - isinstance(exp, int) and exp > time.time() - ), f"JWT exp={exp!r} not a future timestamp (now={time.time():.0f})" + assert isinstance(exp, int) and exp > time.time(), ( + f"JWT exp={exp!r} not a future timestamp (now={time.time():.0f})" + ) diff --git a/tests/lasuite-meet/test_backup.py b/tests/lasuite-meet/test_backup.py index cf480fb..4ead1ed 100644 --- a/tests/lasuite-meet/test_backup.py +++ b/tests/lasuite-meet/test_backup.py @@ -17,6 +17,6 @@ def _psql(domain, sql): def test_backup_captures_state(live_app): - assert ( - _psql(live_app, "SELECT v FROM ci_marker;") == "original" - ), "the seeded postgres state was not present at backup time" + assert _psql(live_app, "SELECT v FROM ci_marker;") == "original", ( + "the seeded postgres state was not present at backup time" + ) diff --git a/tests/lasuite-meet/test_restore.py b/tests/lasuite-meet/test_restore.py index 0b24d9e..2c12801 100644 --- a/tests/lasuite-meet/test_restore.py +++ b/tests/lasuite-meet/test_restore.py @@ -17,6 +17,6 @@ def _psql(domain, sql): def test_restore_returns_state(live_app): - assert ( - _psql(live_app, "SELECT v FROM ci_marker;") == "original" - ), "restore did not return the pre-mutation postgres state" + assert _psql(live_app, "SELECT v FROM ci_marker;") == "original", ( + "restore did not return the pre-mutation postgres state" + ) diff --git a/tests/lasuite-meet/test_upgrade.py b/tests/lasuite-meet/test_upgrade.py index cbf8d80..c1832c5 100644 --- a/tests/lasuite-meet/test_upgrade.py +++ b/tests/lasuite-meet/test_upgrade.py @@ -17,6 +17,6 @@ def _psql(domain, sql): def test_upgrade_preserves_data(live_app): - assert ( - _psql(live_app, "SELECT v FROM ci_marker;") == "upgrade-survives" - ), "postgres data did not survive the upgrade" + assert _psql(live_app, "SELECT v FROM ci_marker;") == "upgrade-survives", ( + "postgres data did not survive the upgrade" + ) diff --git a/tests/mailu/custom/test_mail_flow.py b/tests/mailu/custom/test_mail_flow.py index 1d95360..94a84f6 100644 --- a/tests/mailu/custom/test_mail_flow.py +++ b/tests/mailu/custom/test_mail_flow.py @@ -43,7 +43,7 @@ def test_send_and_receive_mail(live_app): deadline = time.time() + 150 while time.time() < deadline: for box in ("INBOX", "Junk"): - query = f"doveadm search -u '{email_addr}' mailbox {box} " f"header subject '{marker}'" + query = f"doveadm search -u '{email_addr}' mailbox {box} header subject '{marker}'" out = lifecycle.exec_in_app(live_app, ["sh", "-c", query], service="imap") if out.strip(): # a non-empty result = " " → message stored return diff --git a/tests/mailu/custom/test_mailbox.py b/tests/mailu/custom/test_mailbox.py index 09831f6..70db196 100644 --- a/tests/mailu/custom/test_mailbox.py +++ b/tests/mailu/custom/test_mailbox.py @@ -24,6 +24,6 @@ def test_create_mailbox_and_read_back(live_app): cfg = _mailu.config_export(live_app) emails = _mailu.user_emails(cfg) - assert ( - email in emails - ), f"created mailbox {email} not present in mailu config-export users {emails}" + assert email in emails, ( + f"created mailbox {email} not present in mailu config-export users {emails}" + ) diff --git a/tests/matrix-synapse/custom/test_federation_version.py b/tests/matrix-synapse/custom/test_federation_version.py index a6c202f..d08fc44 100644 --- a/tests/matrix-synapse/custom/test_federation_version.py +++ b/tests/matrix-synapse/custom/test_federation_version.py @@ -34,12 +34,12 @@ def test_federation_version_endpoint(live_app): assert status == 200, f"GET {url} HTTP {status} (expected 200)" assert isinstance(body, dict), f"federation version returned non-dict: {type(body).__name__}" server = body.get("server") - assert isinstance( - server, dict - ), f"federation version response missing 'server' envelope: {body!r}" + assert isinstance(server, dict), ( + f"federation version response missing 'server' envelope: {body!r}" + ) name = server.get("name") assert name == "Synapse", f"server.name={name!r}, expected 'Synapse'" version = server.get("version") - assert ( - isinstance(version, str) and len(version) > 0 - ), f"server.version is not a non-empty string: {version!r}" + assert isinstance(version, str) and len(version) > 0, ( + f"server.version is not a non-empty string: {version!r}" + ) diff --git a/tests/matrix-synapse/custom/test_health_check.py b/tests/matrix-synapse/custom/test_health_check.py index 01f1e10..bd08af1 100644 --- a/tests/matrix-synapse/custom/test_health_check.py +++ b/tests/matrix-synapse/custom/test_health_check.py @@ -23,6 +23,6 @@ def test_synapse_client_versions_returns_json(live_app): url = f"https://{live_app}/_matrix/client/versions" status, body = harness_http.retry_http_get(url, expect_status=200, max_wait=60, interval=3) assert status == 200, f"GET {url} HTTP {status} (expected 200)" - assert ( - isinstance(body, dict) and isinstance(body.get("versions"), list) and body["versions"] - ), f"GET {url} did not return Matrix client-versions document: {body!r}" + assert isinstance(body, dict) and isinstance(body.get("versions"), list) and body["versions"], ( + f"GET {url} did not return Matrix client-versions document: {body!r}" + ) diff --git a/tests/matrix-synapse/custom/test_register_and_message.py b/tests/matrix-synapse/custom/test_register_and_message.py index b5c8067..10a1e22 100644 --- a/tests/matrix-synapse/custom/test_register_and_message.py +++ b/tests/matrix-synapse/custom/test_register_and_message.py @@ -127,8 +127,7 @@ def _admin_register(domain: str, secret: str, username: str, password: str, admi if r["status"] == 200: if attempt > 1: print( - f" [register] {username}: succeeded on attempt {attempt} " - f"(synapse recovered)", + f" [register] {username}: succeeded on attempt {attempt} (synapse recovered)", flush=True, ) return r["body"] or {} @@ -177,9 +176,9 @@ def test_register_two_users_send_receive_message(live_app): create + invite + join a room; send and read a message.""" domain = live_app secret = _registration_secret(domain) - assert ( - secret and len(secret) >= 16 - ), f"registration shared secret missing/short: len={len(secret) if secret else 0}" + assert secret and len(secret) >= 16, ( + f"registration shared secret missing/short: len={len(secret) if secret else 0}" + ) suffix = uuid.uuid4().hex[:8] user_a = f"alice{suffix}" diff --git a/tests/matrix-synapse/test_backup.py b/tests/matrix-synapse/test_backup.py index 7799cfb..6902662 100644 --- a/tests/matrix-synapse/test_backup.py +++ b/tests/matrix-synapse/test_backup.py @@ -18,6 +18,6 @@ def _psql(domain, sql): def test_backup_captures_state(live_app): - assert ( - _psql(live_app, "SELECT v FROM ci_marker;") == "original" - ), "the seeded postgres state was not present at backup time" + assert _psql(live_app, "SELECT v FROM ci_marker;") == "original", ( + "the seeded postgres state was not present at backup time" + ) diff --git a/tests/matrix-synapse/test_install.py b/tests/matrix-synapse/test_install.py index d9a9d61..f590504 100644 --- a/tests/matrix-synapse/test_install.py +++ b/tests/matrix-synapse/test_install.py @@ -26,6 +26,6 @@ def test_serving_and_client_api(live_app, meta): # The client-API version document is real synapse JSON (proves the app, not just a proxy 200). body = lifecycle.http_body(live_app, "/_matrix/client/versions") doc = json.loads(body) - assert ( - isinstance(doc.get("versions"), list) and doc["versions"] - ), "no matrix client versions advertised" + assert isinstance(doc.get("versions"), list) and doc["versions"], ( + "no matrix client versions advertised" + ) diff --git a/tests/matrix-synapse/test_restore.py b/tests/matrix-synapse/test_restore.py index 514f13b..f59d815 100644 --- a/tests/matrix-synapse/test_restore.py +++ b/tests/matrix-synapse/test_restore.py @@ -17,6 +17,6 @@ def _psql(domain, sql): def test_restore_returns_state(live_app): - assert ( - _psql(live_app, "SELECT v FROM ci_marker;") == "original" - ), "restore did not return the pre-mutation postgres state" + assert _psql(live_app, "SELECT v FROM ci_marker;") == "original", ( + "restore did not return the pre-mutation postgres state" + ) diff --git a/tests/matrix-synapse/test_upgrade.py b/tests/matrix-synapse/test_upgrade.py index 588998d..6e43103 100644 --- a/tests/matrix-synapse/test_upgrade.py +++ b/tests/matrix-synapse/test_upgrade.py @@ -17,6 +17,6 @@ def _psql(domain, sql): def test_upgrade_preserves_data(live_app): - assert ( - _psql(live_app, "SELECT v FROM ci_marker;") == "upgrade-survives" - ), "postgres data did not survive the upgrade" + assert _psql(live_app, "SELECT v FROM ci_marker;") == "upgrade-survives", ( + "postgres data did not survive the upgrade" + ) diff --git a/tests/mattermost-lts/custom/test_create_message.py b/tests/mattermost-lts/custom/test_create_message.py index 0c066a2..a3efdd0 100644 --- a/tests/mattermost-lts/custom/test_create_message.py +++ b/tests/mattermost-lts/custom/test_create_message.py @@ -41,9 +41,9 @@ def test_create_message_roundtrip(live_app): headers=auth, timeout=30, ) - assert ( - status in (200, 201) and isinstance(team, dict) and team.get("id") - ), f"team creation failed: HTTP {status}, body={team!r}" + assert status in (200, 201) and isinstance(team, dict) and team.get("id"), ( + f"team creation failed: HTTP {status}, body={team!r}" + ) status, chan = harness_http.http_post( f"{base}/channels", data={ @@ -55,9 +55,9 @@ def test_create_message_roundtrip(live_app): headers=auth, timeout=30, ) - assert ( - status in (200, 201) and isinstance(chan, dict) and chan.get("id") - ), f"channel creation failed: HTTP {status}, body={chan!r}" + assert status in (200, 201) and isinstance(chan, dict) and chan.get("id"), ( + f"channel creation failed: HTTP {status}, body={chan!r}" + ) # 4) POST a unique marker message. marker = f"ccci-marker-{uniq}-roundtrip" @@ -67,13 +67,13 @@ def test_create_message_roundtrip(live_app): headers=auth, timeout=30, ) - assert ( - status in (200, 201) and isinstance(post, dict) and post.get("id") - ), f"post creation failed: HTTP {status}, body={post!r}" + assert status in (200, 201) and isinstance(post, dict) and post.get("id"), ( + f"post creation failed: HTTP {status}, body={post!r}" + ) # 5) Read it back by id and assert the message survived the round-trip. status, got = harness_http.http_get(f"{base}/posts/{post['id']}", headers=auth, timeout=30) assert status == 200 and isinstance(got, dict), f"read-back failed: HTTP {status}, body={got!r}" - assert ( - got.get("message") == marker - ), f"message did not round-trip: sent {marker!r}, got {got.get('message')!r}" + assert got.get("message") == marker, ( + f"message did not round-trip: sent {marker!r}, got {got.get('message')!r}" + ) diff --git a/tests/mattermost-lts/custom/test_health_check.py b/tests/mattermost-lts/custom/test_health_check.py index 605caa2..b086e44 100644 --- a/tests/mattermost-lts/custom/test_health_check.py +++ b/tests/mattermost-lts/custom/test_health_check.py @@ -28,6 +28,6 @@ def test_system_ping_ok(live_app): url = f"https://{live_app}/api/v4/system/ping" status, body = harness_http.retry_http_get(url, expect_status=200, max_wait=120, interval=3) assert status == 200, f"GET {url} HTTP {status} (expected 200)" - assert ( - isinstance(body, dict) and body.get("status") == "OK" - ), f"/api/v4/system/ping did not report status=OK; got {body!r}" + assert isinstance(body, dict) and body.get("status") == "OK", ( + f"/api/v4/system/ping did not report status=OK; got {body!r}" + ) diff --git a/tests/mattermost-lts/custom/test_multiuser_message.py b/tests/mattermost-lts/custom/test_multiuser_message.py index 387e436..b97d415 100644 --- a/tests/mattermost-lts/custom/test_multiuser_message.py +++ b/tests/mattermost-lts/custom/test_multiuser_message.py @@ -105,6 +105,6 @@ def test_second_user_reads_first_users_message(live_app): # 5) user_b sees user_a's marker (cross-user delivery, not a self read-back) messages = [p.get("message") for p in (posts.get("posts") or {}).values()] - assert ( - marker in messages - ), f"user_b did not see user_a's message {marker!r} in the channel; saw {messages!r}" + assert marker in messages, ( + f"user_b did not see user_a's message {marker!r} in the channel; saw {messages!r}" + ) diff --git a/tests/mattermost-lts/test_backup.py b/tests/mattermost-lts/test_backup.py index 65f02aa..789d874 100644 --- a/tests/mattermost-lts/test_backup.py +++ b/tests/mattermost-lts/test_backup.py @@ -18,6 +18,6 @@ def _psql(domain, sql): def test_backup_captures_state(live_app): - assert ( - _psql(live_app, "SELECT v FROM ci_marker;") == "original" - ), "the seeded postgres state was not present at backup time" + assert _psql(live_app, "SELECT v FROM ci_marker;") == "original", ( + "the seeded postgres state was not present at backup time" + ) diff --git a/tests/mattermost-lts/test_restore.py b/tests/mattermost-lts/test_restore.py index 88b9b5f..7828787 100644 --- a/tests/mattermost-lts/test_restore.py +++ b/tests/mattermost-lts/test_restore.py @@ -19,6 +19,6 @@ def _psql(domain, sql): def test_restore_returns_state(live_app): - assert ( - _psql(live_app, "SELECT v FROM ci_marker;") == "original" - ), "restore did not return the pre-mutation postgres state" + assert _psql(live_app, "SELECT v FROM ci_marker;") == "original", ( + "restore did not return the pre-mutation postgres state" + ) diff --git a/tests/mattermost-lts/test_upgrade.py b/tests/mattermost-lts/test_upgrade.py index da608a6..f054261 100644 --- a/tests/mattermost-lts/test_upgrade.py +++ b/tests/mattermost-lts/test_upgrade.py @@ -18,6 +18,6 @@ def _psql(domain, sql): def test_upgrade_preserves_data(live_app): - assert ( - _psql(live_app, "SELECT v FROM ci_marker;") == "upgrade-survives" - ), "postgres data did not survive the upgrade" + assert _psql(live_app, "SELECT v FROM ci_marker;") == "upgrade-survives", ( + "postgres data did not survive the upgrade" + ) diff --git a/tests/mumble/custom/_mumble_proto.py b/tests/mumble/custom/_mumble_proto.py index daaa69e..d470109 100644 --- a/tests/mumble/custom/_mumble_proto.py +++ b/tests/mumble/custom/_mumble_proto.py @@ -214,7 +214,7 @@ def handshake( elif msg_type == MSG_REJECT: f = _dec_fields(payload) result["error"] = ( - f"Rejected: {REJECT_TYPES.get(f.get(1, 0), 'Unknown')} " f"— {f.get(2, '')}" + f"Rejected: {REJECT_TYPES.get(f.get(1, 0), 'Unknown')} — {f.get(2, '')}" ) return result elif msg_type == MSG_CHANNELSTATE: diff --git a/tests/mumble/custom/test_protocol_handshake.py b/tests/mumble/custom/test_protocol_handshake.py index 7bc314a..a0aa49f 100644 --- a/tests/mumble/custom/test_protocol_handshake.py +++ b/tests/mumble/custom/test_protocol_handshake.py @@ -25,7 +25,7 @@ def test_handshake_completes_with_channel_presence(live_app): assert r["server_version"] is not None, "server did not send a Version message" assert r["auth_accepted"], f"authentication not accepted — {r.get('error')}" # Channel presence: the server must expose at least the root channel (beyond a bare TCP open). - assert ( - len(r["channels"]) >= 1 - ), f"server reported no channels (expected >=1 root channel) — {r!r}" + assert len(r["channels"]) >= 1, ( + f"server reported no channels (expected >=1 root channel) — {r!r}" + ) assert r["server_sync"], f"ServerSync handshake did not complete — {r.get('error')}" diff --git a/tests/mumble/test_backup.py b/tests/mumble/test_backup.py index 40c051a..334f251 100644 --- a/tests/mumble/test_backup.py +++ b/tests/mumble/test_backup.py @@ -23,6 +23,6 @@ def _sqlite(domain, sql): def test_backup_captures_state(live_app): - assert ( - _sqlite(live_app, "SELECT v FROM ci_marker;") == "original" - ), "the seeded mumble sqlite marker was not present at backup time" + assert _sqlite(live_app, "SELECT v FROM ci_marker;") == "original", ( + "the seeded mumble sqlite marker was not present at backup time" + ) diff --git a/tests/mumble/test_restore.py b/tests/mumble/test_restore.py index 9606ad5..6cfa458 100644 --- a/tests/mumble/test_restore.py +++ b/tests/mumble/test_restore.py @@ -25,6 +25,6 @@ def _sqlite(domain, sql): def test_restore_returns_state(live_app): - assert ( - _sqlite(live_app, "SELECT v FROM ci_marker;") == "original" - ), "restore did not return the pre-mutation mumble sqlite marker (data-integrity failure)" + assert _sqlite(live_app, "SELECT v FROM ci_marker;") == "original", ( + "restore did not return the pre-mutation mumble sqlite marker (data-integrity failure)" + ) diff --git a/tests/n8n/custom/test_login_state.py b/tests/n8n/custom/test_login_state.py index 4768442..1e3e61d 100644 --- a/tests/n8n/custom/test_login_state.py +++ b/tests/n8n/custom/test_login_state.py @@ -91,6 +91,6 @@ def test_login_endpoint_returns_json(live_app): assert body is not None, f"/rest/login returned no parseable JSON: state={state}" # If it's a dict, it's the expected envelope; if it's a list, n8n shouldn't do that on this # endpoint, but accept either; only reject obvious non-shapes. - assert isinstance( - body, dict | list - ), f"/rest/login returned unexpected JSON type {type(body).__name__}: {body!r}" + assert isinstance(body, dict | list), ( + f"/rest/login returned unexpected JSON type {type(body).__name__}: {body!r}" + ) diff --git a/tests/n8n/custom/test_rest_settings.py b/tests/n8n/custom/test_rest_settings.py index bb459fa..792a730 100644 --- a/tests/n8n/custom/test_rest_settings.py +++ b/tests/n8n/custom/test_rest_settings.py @@ -72,9 +72,9 @@ def test_rest_settings_returns_json_with_known_keys(live_app): # (e.g. version 3.2.0+2.20.6). assert isinstance(body, dict), f"/rest/settings returned non-dict JSON: {type(body).__name__}" data = body.get("data") if "data" in body else body - assert isinstance( - data, dict - ), f"/rest/settings response missing 'data' envelope: keys={list(body.keys())[:10]}" + assert isinstance(data, dict), ( + f"/rest/settings response missing 'data' envelope: keys={list(body.keys())[:10]}" + ) # Bootstrap keys the editor SPA relies on across versions: # - `userManagement`: the auth-mode dict (whether owner-setup is needed, smtp/email mode). # - `defaultLocale`: i18n bootstrap; present on every n8n install. diff --git a/tests/n8n/custom/test_workflow_roundtrip.py b/tests/n8n/custom/test_workflow_roundtrip.py index ba8d866..694aff3 100644 --- a/tests/n8n/custom/test_workflow_roundtrip.py +++ b/tests/n8n/custom/test_workflow_roundtrip.py @@ -178,17 +178,17 @@ def test_workflow_create_and_read_back(live_app): workflow_id, str(workflow_id), ), f"GET workflow id={fpayload.get('id')!r} != created id={workflow_id!r}" - assert ( - fpayload.get("name") == name - ), f"workflow name didn't round-trip: created={name!r}, fetched={fpayload.get('name')!r}" + assert fpayload.get("name") == name, ( + f"workflow name didn't round-trip: created={name!r}, fetched={fpayload.get('name')!r}" + ) nodes = fpayload.get("nodes") or [] - assert ( - isinstance(nodes, list) and len(nodes) == 1 - ), f"workflow nodes didn't round-trip: expected 1 node, got {len(nodes)}" + assert isinstance(nodes, list) and len(nodes) == 1, ( + f"workflow nodes didn't round-trip: expected 1 node, got {len(nodes)}" + ) node = nodes[0] - assert ( - node.get("type") == "n8n-nodes-base.manualTrigger" - ), f"node type didn't round-trip: {node.get('type')!r}" - assert ( - node.get("name") == "Manual Trigger" - ), f"node name didn't round-trip: {node.get('name')!r}" + assert node.get("type") == "n8n-nodes-base.manualTrigger", ( + f"node type didn't round-trip: {node.get('type')!r}" + ) + assert node.get("name") == "Manual Trigger", ( + f"node name didn't round-trip: {node.get('name')!r}" + ) diff --git a/tests/n8n/test_backup.py b/tests/n8n/test_backup.py index 4e01d8a..934f1ae 100644 --- a/tests/n8n/test_backup.py +++ b/tests/n8n/test_backup.py @@ -14,6 +14,6 @@ MARKER = "/home/node/.n8n/ci-marker.txt" def test_backup_captures_state(live_app): - assert ( - lifecycle.exec_in_app(live_app, ["cat", MARKER]).strip() == "original" - ), "the seeded state was not present at backup time" + assert lifecycle.exec_in_app(live_app, ["cat", MARKER]).strip() == "original", ( + "the seeded state was not present at backup time" + ) diff --git a/tests/n8n/test_restore.py b/tests/n8n/test_restore.py index 2f6682c..ab743b7 100644 --- a/tests/n8n/test_restore.py +++ b/tests/n8n/test_restore.py @@ -14,6 +14,6 @@ MARKER = "/home/node/.n8n/ci-marker.txt" def test_restore_returns_state(live_app): - assert ( - lifecycle.exec_in_app(live_app, ["cat", MARKER]).strip() == "original" - ), "restore did not return the pre-mutation state" + assert lifecycle.exec_in_app(live_app, ["cat", MARKER]).strip() == "original", ( + "restore did not return the pre-mutation state" + ) diff --git a/tests/n8n/test_upgrade.py b/tests/n8n/test_upgrade.py index 98bbdbd..35000d9 100644 --- a/tests/n8n/test_upgrade.py +++ b/tests/n8n/test_upgrade.py @@ -14,6 +14,6 @@ MARKER = "/home/node/.n8n/ci-marker.txt" def test_upgrade_preserves_data(live_app): - assert ( - lifecycle.exec_in_app(live_app, ["cat", MARKER]).strip() == "upgrade-survives" - ), "data did not survive the upgrade" + assert lifecycle.exec_in_app(live_app, ["cat", MARKER]).strip() == "upgrade-survives", ( + "data did not survive the upgrade" + ) diff --git a/tests/plausible/test_backup.py b/tests/plausible/test_backup.py index 0f2e4be..66cc819 100644 --- a/tests/plausible/test_backup.py +++ b/tests/plausible/test_backup.py @@ -14,6 +14,6 @@ def _psql(domain, sql): def test_backup_captures_state(live_app): - assert ( - _psql(live_app, "SELECT v FROM ci_marker;") == "original" - ), "seeded postgres state not present at backup time" + assert _psql(live_app, "SELECT v FROM ci_marker;") == "original", ( + "seeded postgres state not present at backup time" + ) diff --git a/tests/plausible/test_restore.py b/tests/plausible/test_restore.py index 2352175..3396075 100644 --- a/tests/plausible/test_restore.py +++ b/tests/plausible/test_restore.py @@ -14,6 +14,6 @@ def _psql(domain, sql): def test_restore_returns_state(live_app): - assert ( - _psql(live_app, "SELECT v FROM ci_marker;") == "original" - ), "restore did not return the pre-mutation postgres state" + assert _psql(live_app, "SELECT v FROM ci_marker;") == "original", ( + "restore did not return the pre-mutation postgres state" + ) diff --git a/tests/plausible/test_upgrade.py b/tests/plausible/test_upgrade.py index dd1bf0e..6850b40 100644 --- a/tests/plausible/test_upgrade.py +++ b/tests/plausible/test_upgrade.py @@ -14,6 +14,6 @@ def _psql(domain, sql): def test_upgrade_preserves_data(live_app): - assert ( - _psql(live_app, "SELECT v FROM ci_marker;") == "upgrade-survives" - ), "postgres data did not survive the upgrade" + assert _psql(live_app, "SELECT v FROM ci_marker;") == "upgrade-survives", ( + "postgres data did not survive the upgrade" + ) diff --git a/tests/regression/test_canaries.py b/tests/regression/test_canaries.py index 361fabd..e34a44d 100644 --- a/tests/regression/test_canaries.py +++ b/tests/regression/test_canaries.py @@ -229,13 +229,13 @@ def _assert_green(rc: int, results: dict | None, canary: dict, note: str) -> Non # 1. Harness exit code must be 0 (GREEN). assert rc == 0, f"[{canary['id']}] harness returned non-zero rc={rc} — expected GREEN. {note}" - assert ( - results is not None - ), f"[{canary['id']}] results.json not written — harness may have crashed. {note}" + assert results is not None, ( + f"[{canary['id']}] results.json not written — harness may have crashed. {note}" + ) # 2. Install tier must have passed. assert results.get("results", {}).get("install") == "pass", ( - f"[{canary['id']}] install tier did not pass: " f"results={results.get('results')}. {note}" + f"[{canary['id']}] install tier did not pass: results={results.get('results')}. {note}" ) # 3. No tier may have FAILED (skips are acceptable for recipes without backup or custom tests). @@ -243,14 +243,14 @@ def _assert_green(rc: int, results: dict | None, canary: dict, note: str) -> Non assert not failed_tiers, f"[{canary['id']}] tiers failed: {failed_tiers}. {note}" # 4. Teardown must be clean (no leftover containers/volumes/secrets). - assert ( - results.get("flags", {}).get("clean_teardown") is True - ), f"[{canary['id']}] clean_teardown=False — residual state left on server. {note}" + assert results.get("flags", {}).get("clean_teardown") is True, ( + f"[{canary['id']}] clean_teardown=False — residual state left on server. {note}" + ) # 5. No secret values leaked into the results artifact. - assert ( - results.get("flags", {}).get("no_secret_leak") is True - ), f"[{canary['id']}] no_secret_leak=False — a secret value appeared in results.json. {note}" + assert results.get("flags", {}).get("no_secret_leak") is True, ( + f"[{canary['id']}] no_secret_leak=False — a secret value appeared in results.json. {note}" + ) # 6. Semantic stage assertions — TEETH CHECK. # These verify that specific named tests actually ran and passed in the expected stage. diff --git a/tests/unit/test_dashboard.py b/tests/unit/test_dashboard.py index 67cc5d6..0dec211 100644 --- a/tests/unit/test_dashboard.py +++ b/tests/unit/test_dashboard.py @@ -174,10 +174,17 @@ def test_level_badge_shows_level_coloured(monkeypatch): def _write_run(base, run_id, recipe, finished, **kw): d = os.path.join(base, run_id) os.makedirs(d, exist_ok=True) - doc = {"recipe": recipe, "finished": finished, "run_id": run_id, - "ref": kw.get("ref", "deadbeefcafe"), "version": kw.get("version"), - "level": kw.get("level", 5), "screenshot": kw.get("screenshot", "screenshot.png"), - "results": kw.get("results", {"install": "pass"}), "flags": kw.get("flags", {})} + doc = { + "recipe": recipe, + "finished": finished, + "run_id": run_id, + "ref": kw.get("ref", "deadbeefcafe"), + "version": kw.get("version"), + "level": kw.get("level", 5), + "screenshot": kw.get("screenshot", "screenshot.png"), + "results": kw.get("results", {"install": "pass"}), + "flags": kw.get("flags", {}), + } with open(os.path.join(d, "results.json"), "w") as fh: json.dump(doc, fh) @@ -193,8 +200,12 @@ def test_history_sourced_from_local_artifacts(tmp_path, monkeypatch): # mixed numeric + named ids; out-of-order on disk; the timestamp MUST decide order, not the id _write_run(base, "753", "bsky", 1781663348, results={"install": "pass"}) _write_run(base, "427", "bsky", 1781178768, results={"install": "pass"}) - _write_run(base, "m2r-bsky", "bsky", 1781121610, level=0, results={"install": "pass", "backup": "fail"}) - _write_run(base, "423", "bsky", 1781178063, results={"install": "pass"}) # 423<427 numerically but OLDER + _write_run( + base, "m2r-bsky", "bsky", 1781121610, level=0, results={"install": "pass", "backup": "fail"} + ) + _write_run( + base, "423", "bsky", 1781178063, results={"install": "pass"} + ) # 423<427 numerically but OLDER _write_run(base, "9", "other", 1781000000) # different recipe, must not leak in # graceful-skip cases (the host's in-flight/failed-early dirs) os.makedirs(os.path.join(base, "EMPTY"), exist_ok=True) # in-flight dir, no results.json diff --git a/tests/unit/test_f211_sso_skip.py b/tests/unit/test_f211_sso_skip.py index bca4297..d014f6e 100644 --- a/tests/unit/test_f211_sso_skip.py +++ b/tests/unit/test_f211_sso_skip.py @@ -66,7 +66,7 @@ def _load_conftest(): class _FakeItem: def __init__(self, keywords): # pytest `item.keywords` supports `in`; a dict suffices. - self.keywords = {k: True for k in keywords} + self.keywords = dict.fromkeys(keywords, True) self.markers = [] def add_marker(self, mark): diff --git a/tests/unit/test_gitea_dep.py b/tests/unit/test_gitea_dep.py index a573e96..dbe4b3b 100644 --- a/tests/unit/test_gitea_dep.py +++ b/tests/unit/test_gitea_dep.py @@ -176,6 +176,5 @@ def test_scm_redirect_assertions(location_url, gitea_domain, client_id, expect_p ] all_pass = all(checks) assert all_pass == expect_pass, ( - f"Expected {'pass' if expect_pass else 'fail'} for URL {location_url!r}; " - f"checks: {checks}" + f"Expected {'pass' if expect_pass else 'fail'} for URL {location_url!r}; checks: {checks}" ) diff --git a/tests/uptime-kuma/custom/test_spa_branding.py b/tests/uptime-kuma/custom/test_spa_branding.py index f7e6d21..2b629c6 100644 --- a/tests/uptime-kuma/custom/test_spa_branding.py +++ b/tests/uptime-kuma/custom/test_spa_branding.py @@ -42,9 +42,9 @@ def test_uptime_kuma_spa_has_branding(live_app): body = harness_http.assert_converges(_ready, f"GET {url}", max_wait=60, interval=3) lower = body.lower() - assert ( - "uptime kuma" in lower or "kuma" in lower - ), f"Page body has no 'kuma' brand. Excerpt: {body[:200]!r}" + assert "uptime kuma" in lower or "kuma" in lower, ( + f"Page body has no 'kuma' brand. Excerpt: {body[:200]!r}" + ) # SPA-bundle markers: at least one of these reference paths should be present bundle_markers = ("/assets/", "/icon.svg", "favicon", "main.") present = [m for m in bundle_markers if m in body]