Default routine log reps from targets
Some checks failed
secret-guardrails / artifact-secret-scan (push) Has been cancelled
secret-guardrails / gitleaks (push) Has been cancelled

This commit is contained in:
Fizzlepoof
2026-05-28 20:55:22 +00:00
parent 64e7ac82cf
commit dd4134b1ce
3 changed files with 52 additions and 2 deletions

View File

@@ -464,6 +464,47 @@ def test_seeded_routine_log_submission_creates_structured_workout(tmp_path: Path
assert payload[0]['exercises'][1]['exercise_name'] == 'Upright Row'
def test_seeded_routine_log_uses_numeric_target_reps_when_reps_left_blank(tmp_path: Path) -> None:
client = make_client(tmp_path)
summary = client.get('/api/dashboard/summary').json()
shoulders = next(routine for routine in summary['routines'] if routine['name'] == 'Thursday: Shoulders')
response = client.post(
'/workouts/routine-log',
data={
'user_id': 'john',
'routine_id': shoulders['id'],
'performed_at': '2026-05-28T12:00:00',
'routine_name': shoulders['name'],
'notes': 'Use default target reps when left blank.',
'exercise_count': '1',
'exercise_0_name': 'Shoulder Press',
'exercise_0_set_count': '3',
'exercise_0_set_0_reps': '',
'exercise_0_set_0_weight_lbs': '45',
'exercise_0_set_1_reps': '',
'exercise_0_set_1_weight_lbs': '45',
'exercise_0_set_2_reps': '',
'exercise_0_set_2_weight_lbs': '45',
},
follow_redirects=False,
)
assert response.status_code == 303
assert response.headers['location'] == '/'
workout_history = client.get('/api/history/john/workouts')
assert workout_history.status_code == 200
payload = workout_history.json()
assert payload[0]['routine_name'] == 'Thursday: Shoulders'
assert payload[0]['exercises'][0]['sets'] == [
{'reps': 10, 'weight_lbs': 45.0},
{'reps': 10, 'weight_lbs': 45.0},
{'reps': 10, 'weight_lbs': 45.0},
]
def test_existing_state_gets_seeded_routine_backfill(tmp_path: Path) -> None:
state_path = tmp_path / 'state.json'
state_path.write_text(