"""Component field coverage. Reading only Name/Comment silently dropped the actual movements -- the metcon lives in Description and the strength scheme in MeasureRepScheme. These tests exist so that regression cannot recur quietly. """ from __future__ import annotations from wodify import render STRENGTH = { "Id": "123372266", "IsWeightlifting": True, "Name": "Shoulder Press", "Comment": "

--

Strict overhead pressing progression.

", "MeasureRepScheme": "Strict Press\nEvery 2:30 x 4 Sets\nSet 1: 10 Reps", "WODComponentVariableRepScheme": "(1 x 10) (1 x 8) (1 x 6) (1 x 4)", "WODComponentOrder": 2, } METCON = { "Id": "123372267", "IsMetcon": True, "Name": '"Hat Trick"', "Comment": "

Goals: ~2:00 per set

RPE: 9/10

", "Description": "

For Time

Every 5:00 x 3 Sets

21 Wall Balls

", "Rounds": 3, "EachRoundTypeLabel": "For Time ↓ Shorter is Better", "WODComponentOrder": 3, } SECTION = {"Id": "1", "IsSection": True, "Name": "WARM-UP", "Comment": "

2:00 Cardio Choice

", "WODComponentOrder": 1} def _wod(components): return {"Response": {"ResponseWOD": {"ResponseWorkout": { "Id": "25201299", "Name": "CrossFit - Mon, Jul 20", "Notes": "", "WorkoutComponents": {"List": components}, }}}} def test_metcon_description_is_rendered(): """Description carries the movements. Without it the output looks complete but contains no workout.""" out = render.workout(_wod([METCON])) assert "21 Wall Balls" in out assert "Every 5:00 x 3 Sets" in out def test_strength_rep_scheme_is_rendered(): out = render.workout(_wod([STRENGTH])) assert "Every 2:30 x 4 Sets" in out assert "Set 1: 10 Reps" in out def test_variable_rep_scheme_included_when_distinct(): assert "(1 x 10) (1 x 8)" in render.workout(_wod([STRENGTH])) def test_variable_rep_scheme_not_duplicated(): comp = dict(STRENGTH, WODComponentVariableRepScheme="Every 2:30 x 4 Sets") out = render.workout(_wod([comp])) assert out.count("Every 2:30 x 4 Sets") == 1 def test_rounds_and_scoring_are_surfaced(): out = render.workout(_wod([METCON])) assert "3 rounds" in out assert "Shorter is Better" in out def test_dash_only_comment_is_dropped(): """Authors use '--' as a spacer; it should not appear as content.""" comp = {"Id": "9", "Name": "Press", "Comment": "

--

", "WODComponentOrder": 1} out = render.workout(_wod([comp])) assert "--" not in out def test_real_comment_is_kept(): assert "RPE: 9/10" in render.workout(_wod([METCON])) def test_dash_spacer_stripped_but_surrounding_comment_kept(): """Live data has '--' as a leading spacer before real prose.""" out = render.workout(_wod([STRENGTH])) assert "Strict overhead pressing progression." in out assert "--" not in out def test_components_sorted_by_wod_component_order(): out = render.workout(_wod([METCON, SECTION, STRENGTH])) assert out.index("WARM-UP") < out.index("Shoulder Press") < out.index("Hat Trick") def test_section_and_component_heading_levels_differ(): out = render.workout(_wod([SECTION, METCON])) assert "## WARM-UP" in out assert '### "Hat Trick"' in out def test_missing_order_does_not_crash(): comp = {k: v for k, v in METCON.items() if k != "WODComponentOrder"} assert "21 Wall Balls" in render.workout(_wod([comp]))