feat: extend media roles and acceptance coverage
CI / backend-and-migrations (push) Waiting to run
CI / astro-build (push) Waiting to run
CI / dependency-audit (push) Waiting to run
CI / compose-e2e (push) Waiting to run

This commit is contained in:
ik
2026-09-20 18:30:16 +07:00
parent e94d247096
commit a547d09fcd
6 changed files with 42 additions and 7 deletions
+23
View File
@@ -173,6 +173,29 @@ def test_waterbody_media_role_rejects_unknown_role(tmp_path: Path) -> None:
)
def test_tackle_media_roles_require_explicit_review_and_matching_entity(tmp_path: Path) -> None:
manifest = tmp_path / "manifest.json"
candidate = extract_media_candidates(
'<img src="/lure/spiker.webp" alt="Блесна Спайкер">',
source_page="https://rf4db.com/ru/wiki/lures/spiker",
)[0]
merge_manifest(manifest, [candidate])
with pytest.raises(ValueError, match="known tackle role"):
review_asset(
manifest, asset_url=candidate.asset_url, decision="rejected",
entity_type="tackle", entity_key="tackle:spiker", media_role="waterbody_map",
)
saved = json.loads(manifest.read_text(encoding="utf-8"))
saved["assets"][0].update({"status": "stored", "sha256": "a" * 64, "local_path": "files/spiker.webp", "width": 256, "height": 256, "content_type": "image/webp"})
manifest.write_text(json.dumps(saved), encoding="utf-8")
reviewed = review_asset(
manifest, asset_url=candidate.asset_url, decision="approved",
entity_type="tackle", entity_key="tackle:spiker", media_role="tackle_card",
)
assert reviewed["media_role"] == "tackle_card"
def test_image_inspection_rejects_invalid_body_and_mime_mismatch(tmp_path: Path) -> None:
with pytest.raises(ValueError, match="valid raster"):
inspect_image(b"not an image")