- endpoint moved: WodifyClient_Class/Classes/Class/ActionGetClassAttendees (old Schedule_OS GetClassAttendees no longer fires anywhere in the app) - render.attendees() delegates to attendee_rows() — PersonName, not Name - test fixtures updated to ClassDetailAttendee.List wire shape - CLAUDE.md: diagnosis notes (path re-prefix + lazy attendee action) prime now captures 8/8 actions; 138 tests pass
76 lines
2.5 KiB
Python
76 lines
2.5 KiB
Python
"""Rendering exists to keep output small. Verify shaping, not exact prose."""
|
|
from __future__ import annotations
|
|
|
|
from wodify import render
|
|
|
|
|
|
def test_flatten_html_turns_breaks_into_lines():
|
|
raw = "<p>For Time</p><p>30 Power Cleans<br>30 Toes-to-Bars</p>"
|
|
out = render.flatten_html(raw)
|
|
assert "For Time" in out
|
|
assert "30 Power Cleans" in out
|
|
assert "<" not in out
|
|
|
|
|
|
def test_flatten_html_unescapes_entities():
|
|
assert render.flatten_html("<p>135/95lb & 24"</p>") == '135/95lb & 24"'
|
|
|
|
|
|
def test_flatten_html_handles_none_and_empty():
|
|
assert render.flatten_html(None) == ""
|
|
assert render.flatten_html("") == ""
|
|
|
|
|
|
def test_flatten_html_collapses_runs_of_blank_lines():
|
|
assert "\n\n\n" not in render.flatten_html("a<br><br><br><br>b")
|
|
|
|
|
|
def test_find_all_reaches_nested_values():
|
|
data = {"a": {"b": [{"Description": "x"}, {"c": {"Description": "y"}}]}}
|
|
assert render.find_all(data, "Description") == ["x", "y"]
|
|
|
|
|
|
def test_first_list_skips_empty_lists():
|
|
data = {"p": {"List": []}, "q": {"List": [{"Id": 1}]}}
|
|
assert render.first_list(data) == [{"Id": 1}]
|
|
|
|
|
|
def test_bookings_reports_absence_rather_than_empty_string():
|
|
assert "No bookings" in render.bookings({"Response": {"List": []}})
|
|
|
|
|
|
def test_bookings_formats_rows():
|
|
data = {"Response": {"List": [
|
|
{"Class": {"StartDate": "2026-07-27", "StartTime": "5:30 PM",
|
|
"ClassName": "CrossFit: 5:30 PM"},
|
|
"StatusLabel": "Reserved"},
|
|
]}}
|
|
out = render.bookings(data)
|
|
assert "2026-07-27" in out and "CrossFit: 5:30 PM" in out and "[Reserved]" in out
|
|
|
|
|
|
def test_attendees_counts_and_lists():
|
|
# Current wire shape (2026-08 redesign): ClassDetailAttendee.List with
|
|
# PersonName. The pre-redesign {"Response": {"List": [{"Name": ...}]}}
|
|
# shape is covered by attendee_rows' fallbacks; the CLI view must render
|
|
# the shape the service actually returns today.
|
|
data = {"Response": {"ClassDetailAttendee": {"List": [
|
|
{"PersonName": "A B", "StatusInClass": "Reserved"},
|
|
{"PersonName": "C D", "StatusInClass": "Reserved"},
|
|
]}}}
|
|
out = render.attendees(data)
|
|
assert out.startswith("2 attendees:") and "A B" in out and "C D" in out
|
|
|
|
|
|
def test_attendees_reports_absence():
|
|
assert "No attendees" in render.attendees({"Response": {"List": []}})
|
|
|
|
|
|
def test_workout_reports_absence():
|
|
assert "No workout content" in render.workout({"Response": {}})
|
|
|
|
|
|
def test_render_falls_back_to_json_for_unmapped_actions():
|
|
out = render.render("classdetail", {"Response": {"Id": 1}})
|
|
assert '"Id": 1' in out
|