Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions test/e2e/test_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def get_json(api: APIRequestContext, path: str) -> dict:

def json_twin(url: str) -> str:
"""
Path of a page's JSON twin: its URL with .json for the trailing slash (refs carry no json_url)
Path of a page's JSON twin: its URL with .json for the trailing slash (only episodes.json entries carry json_url)
"""
return urlparse(url).path.rstrip("/") + ".json"

Expand Down Expand Up @@ -245,8 +245,9 @@ def test_show_json_links_resolve(api_request_context: APIRequestContext, show: S
"""
latest = get_json(api_request_context, f"/show/{show.slug}/show.json")["latest_episode"]
oldest = get_json(api_request_context, f"/show/{show.slug}/episodes.json")["episodes"][-1]
assert "json_url" not in latest, "a ref outside episodes.json carries no json_url"
assert urlparse(oldest["json_url"]).path == json_twin(oldest["url"]), "episodes.json entries link their JSON twin"
for ref in (latest, oldest):
assert "json_url" not in ref, "an episode's JSON is its url with .json"
episode = get_json(api_request_context, json_twin(ref["url"]))
assert episode["type"] == "episode"
assert episode["episode"] == ref["episode"]
Expand All @@ -261,7 +262,7 @@ def test_every_episode_json_is_valid(api_request_context: APIRequestContext, sho
entries = get_json(api_request_context, f"/show/{show.slug}/episodes.json")["episodes"]
problems = []
for entry in entries:
path = json_twin(entry["url"])
path = urlparse(entry["json_url"]).path
response = api_request_context.get(path)
content_type = response.headers.get("content-type", "")
if response.status != 200 or not content_type.startswith("application/json"):
Expand Down
3 changes: 2 additions & 1 deletion test/e2e/test_llms.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,8 @@ def test_show_episodes_json(api_request_context: APIRequestContext, show: Show):

for ep in data["episodes"]:
slug = ep["url"].rstrip("/").rsplit("/", 1)[-1]
assert set(ep) == {"episode", "title", "date", "url", "markdown_url"}, f"{slug}: {sorted(ep)} (no json_url: it is the url with .json)"
assert set(ep) == {"episode", "title", "date", "url", "json_url", "markdown_url"}, f"{slug}: {sorted(ep)}"
assert re.fullmatch(rf"{HOST}/show/{show.slug}/{re.escape(slug)}\.json", ep["json_url"]), ep["json_url"]
assert ep["title"], f"{slug}: empty title"
assert re.fullmatch(rf"{HOST}/show/{show.slug}/{re.escape(slug)}/", ep["url"]), ep["url"]
assert re.fullmatch(rf"{HOST}/show/{show.slug}/{re.escape(slug)}\.md", ep["markdown_url"]), ep["markdown_url"]
Expand Down
2 changes: 1 addition & 1 deletion themes/jb/layouts/show/list.episodes.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
"count": {{ len $eps }},
"episodes": [
{{ range $i, $p := $eps.ByDate.Reverse }}{{ if $i }},
{{ end }} {{ partial "json-episode-ref.html" $p | jsonify (dict "noHTMLEscape" true) }}{{ end }}
{{ end }} {{ $ref := partial "json-episode-ref.html" $p }}{{ with $p.OutputFormats.Get "json" }}{{ $ref = merge $ref (dict "json_url" .Permalink) }}{{ end }}{{ $ref | jsonify (dict "noHTMLEscape" true) }}{{ end }}
]
}