Commit f8b7b41e by PLN (Algolia)

fix(catalog_view): fail loud when site content (corner C) is missing

build_catalog_view silently returned 0 tracks when www is on a branch without
next/content/lives (the redesign branch) — which would let tide.py build clobber the
good catalog_view.json with an empty one. Now raises a clear error; IT fixtures skip
cleanly when the external site dep is unavailable. Suite: 49 passed, 17 skipped.
parent 0f0331ac
......@@ -57,6 +57,14 @@ DN_HINT = re.compile(r"\bd(\d{1,2})\b")
# ── corner C: site gig tracklists ────────────────────────────────────────────
def load_gigs():
# Corner C lives in the www repo's working tree. If www is checked out to a branch
# without the content (e.g. the redesign branch), refuse to build an empty catalog —
# a vanished input must fail LOUD, never silently zero the corpus (and never let
# `tide.py build` clobber the good catalog_view.json). [[feedback_parsers_over_copy]]
if not LIVES.is_dir():
raise RuntimeError(
f"site content not found at {LIVES} — is the www repo on the right branch? "
"corner-C (gig tracklists) is missing; refusing to build an empty catalog.")
gigs = {}
for f in glob.glob(str(LIVES / "**/tracks.json"), recursive=True):
slug = str(Path(f).parent.relative_to(LIVES))
......@@ -67,6 +75,8 @@ def load_gigs():
tracks = d.get("tracks") if isinstance(d, dict) else d
dt = (d.get("date") if isinstance(d, dict) else None) or ""
gigs[slug] = {"date": dt[:10], "tracks": tracks or []}
if not gigs:
raise RuntimeError(f"no tracks.json found under {LIVES} — site content empty/moved.")
return gigs
......
......@@ -26,13 +26,28 @@ def fixtures():
@pytest.fixture(scope="session")
def view():
"""The real pipeline output, built once (IT-on-real-data)."""
"""The real pipeline output, built once (IT-on-real-data). Skips cleanly when the
site content (corner C, in the www repo) is unavailable — e.g. www checked out to a
branch without next/content/lives — since these IT tests depend on that external repo."""
import build_catalog_view as bcv
return bcv.build()
try:
v = bcv.build()
except RuntimeError as e:
pytest.skip(f"site content unavailable: {e}")
if not (v["tracks"] if isinstance(v, dict) else v.tracks):
pytest.skip("site content unavailable (0 tracks) — www on a contentless branch?")
return v
@pytest.fixture(scope="session")
def registry():
"""The real pattern registry, built once (IT-on-real-data)."""
"""The real pattern registry, built once (IT-on-real-data). Skips when the site
content is unavailable (same external www dependency as `view`)."""
import pattern_ngrams as pn
return pn.build()
try:
r = pn.build()
except RuntimeError as e:
pytest.skip(f"site content unavailable: {e}")
if not r.get("tracks"):
pytest.skip("site content unavailable (0 tracks) — www on a contentless branch?")
return r
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment