Files
lucioandClaude Opus 5 8ab4ad4b17 fix: remove dead Home-variant GetClasses; classes now aliases schedule
The remaining open item. Probing settled it: the Home-variant GetClasses
returns placeholder records even when the real client calls it -- confirmed by
capturing the app's own request/response pair during a live walk (200, ~10 KB,
zero real records, empty ScheduleList). Every screen-variable override
(WBDataFetchIsComplete, IsLoading, ProgramsWithHistory, all date/program
combos) changes nothing. It is not parameter-gated; it is empty by design.

So the fix is honesty, not persistence: the action is removed from the
allowlist (a test pins it out so it cannot quietly return), and `wodify
classes` becomes an argparse alias of `schedule`, the class-list action that
actually returns data. `schedule` also gains the default-to-today behaviour
the old command had.

134 tests, no network required.

Co-Authored-By: Claude Opus 5 <[email protected]>
2026-07-25 15:44:41 -07:00

88 lines
3.4 KiB
Python

"""The read-only guard is the only thing preventing this client from spending
the user's money or taking someone's class spot. Test it hard."""
from __future__ import annotations
import pytest
from wodify import actions
def test_every_registered_action_is_read_only():
for key, action in actions.ACTIONS.items():
actions.assert_read_only(action.path) # must not raise
assert action.key == key, "registry key must match Action.key"
assert action.path, f"{key} has no path"
assert not action.path.startswith("/"), f"{key} path should be relative"
def test_get_returns_action():
assert actions.get("bookings").key == "bookings"
def test_unknown_action_rejected():
with pytest.raises(actions.UnknownActionError):
actions.get("definitely-not-a-real-action")
# Real mutating endpoint names observed in Wodify's client, plus plausible
# variants. None may ever pass the guard.
@pytest.mark.parametrize("path", [
"WodifyClient_Class/Classes/Class/ServiceAPICreateClassReservation",
"WodifyClient_Class/Classes/Class/ActionCancelReservation",
"WodifyClient_DataFetch_WB/WOD_Flow/SaveWorkoutResult",
"WodifyClient/Common/ActionAcceptTermsAndConditions",
"WodifyClient_Class/Classes/Class/ClientActionSignInToClass",
"WodifyClient/MainScreens/ActionSubmitAppReview",
"WodifyClient_Class/Classes/ActionLeaveWaitlist",
"WodifyClient/Account/ActionLogout",
"WodifyClient/POS/ActionPurchaseItem",
"WodifyClient/WOD/ActionAddResult",
])
def test_write_endpoints_are_refused(path):
with pytest.raises(actions.WriteAttemptError):
actions.assert_read_only(path)
def test_guard_is_case_insensitive():
with pytest.raises(actions.WriteAttemptError):
actions.assert_read_only("Module/Screen/ACTIONCREATERESERVATION")
def test_guard_does_not_block_legitimate_read_paths():
"""Guard markers must not false-positive on the reads we actually need.
'GetClassWaitList' in particular has to stay callable -- reading a waitlist
is fine, joining or leaving it is not.
"""
safe = [
"WodifyClient_DataFetch_WB/Schedule_OS/GetClassWaitList_WB/DataActionGetClassWaitList",
"WodifyClient_DataFetch_WB/Schedule_OS/GetClassAttendees_WB/DataActionGetClassAttendees",
"WodifyClient_DataFetch_WB/WOD_Flow/GetWorkoutData_HasWodLeaderboardComponents"
"/DataActionGetWorkoutDataHasWodLeaderboardComponents",
"WodifyClient_Class/Classes/Attendance/DataActionGetClasses",
]
for path in safe:
actions.assert_read_only(path)
def test_all_expected_actions_registered():
expected = {"bookings", "workout", "wodflags", "attendees", "classdetail",
"coach", "schedule", "waitlist"}
assert expected <= set(actions.keys())
def test_dead_home_getclasses_is_not_registered():
"""The Home-variant GetClasses returns placeholders even when the real
client calls it (confirmed live). It must stay out of the allowlist so
nothing reports its empty response as a real answer."""
assert "classes" not in actions.ACTIONS
for action in actions.ACTIONS.values():
assert "Classes/Attendance/DataActionGetClasses" not in action.path
def test_get_returns_action_for_workout_probe():
"""wodflags is deliberately not called 'workout': it returns a boolean, and
naming it 'workout' invited reporting 'no workout' from a probe response."""
action = actions.get("wodflags")
assert "NOT the workout text" in action.summary