feat: add responsive CHRNX podcast atmosphere

This commit is contained in:
chrnx committed 2026-08-13 01:01:08 -05:00
1 parent 3840b7c168
commit 6443a46126
13 files changed
+190 -18

No files matched your search

+45
View File
@@ -1,3 +1,4 @@
import json
import shutil
import subprocess
import sys
@@ -9,6 +10,7 @@ from PIL import Image
PROJECT_ROOT = Path(__file__).resolve().parents[2]
ASSET_DIRECTORY = PROJECT_ROOT / "assets" / "images"
GENERATED_DIRECTORY = ASSET_DIRECTORY / "generated"
ALTER_EGO_ASSETS = (
"alter-ego-code.png",
"alter-ego-literature.png",
@@ -19,6 +21,12 @@ ALTER_EGO_ASSETS = (
)
ALTER_EGO_SOURCE_ASSETS = (*ALTER_EGO_ASSETS, "alter-ego-gaming-half-body.png")
BACKGROUND_ASSETS = ("podcast-frequency-grunge.png",)
PODCAST_DERIVATIVES = tuple(
f"podcast-frequency-grunge-{width}.{extension}"
for width in (384, 768, 1536)
for extension in ("avif", "webp")
)
PODCAST_MANIFEST = "podcast-frequency-grunge.json"
CONTACT_SHEET_SCRIPT = PROJECT_ROOT / "scripts" / "build-alter-ego-contact-sheet.py"
@@ -144,6 +152,43 @@ def test_background_asset_inventory_and_image_contract() -> None:
)
def test_podcast_responsive_derivative_inventory_manifest_and_budgets() -> None:
generated_names = sorted(path.name for path in GENERATED_DIRECTORY.iterdir())
assert len(generated_names) == 52, (
f"generated inventory expected 52 files, got {len(generated_names)}"
)
for name in (*PODCAST_DERIVATIVES, PODCAST_MANIFEST):
assert name in generated_names, f"missing {name}"
manifest = json.loads((GENERATED_DIRECTORY / PODCAST_MANIFEST).read_text())
assert manifest == {
"source": "podcast-frequency-grunge.png",
"formats": ["avif", "webp"],
"widths": [384, 768, 1536],
}
family_total = 0
for name in PODCAST_DERIVATIVES:
size = (GENERATED_DIRECTORY / name).stat().st_size
width = int(name.rsplit("-", 1)[1].split(".", 1)[0])
limit = 260 * 1024 if width == 1536 else 160 * 1024
assert size <= limit, f"{name} exceeds {limit} bytes: {size} bytes"
family_total += size
assert family_total <= 620 * 1024, (
"podcast-frequency-grunge family exceeds 620 KiB: "
f"{family_total} total bytes"
)
binary_total = sum(
path.stat().st_size
for path in GENERATED_DIRECTORY.iterdir()
if path.suffix in {".avif", ".webp"}
)
assert binary_total <= 2.75 * 1024 * 1024, (
f"generated binary payload exceeds 2.75 MiB: {binary_total} total bytes"
)
def test_background_contract_rejects_corrupt_idat_data(
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
) -> None: