Default routine log reps from targets
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user