Add structured routine logging sheets to Doris Barbell
This commit is contained in:
@@ -374,6 +374,73 @@ def test_homepage_renders_core_sections_and_forms(tmp_path: Path) -> None:
|
||||
assert 'Monday: Chest' in body
|
||||
|
||||
|
||||
def test_seeded_routine_can_render_prefilled_log_sheet(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.get(f"/routines/{shoulders['id']}/log")
|
||||
|
||||
assert response.status_code == 200
|
||||
body = response.text
|
||||
assert 'Thursday: Shoulders' in body
|
||||
assert 'Shoulder Press' in body
|
||||
assert 'Save shoulder day workout' in body
|
||||
assert 'name="exercise_0_set_0_reps"' in body
|
||||
assert 'name="exercise_0_set_0_weight_lbs"' in body
|
||||
assert 'value="10"' in body
|
||||
|
||||
|
||||
def test_seeded_routine_log_submission_creates_structured_workout(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': 'Shoulder day at the gym.',
|
||||
'exercise_count': '2',
|
||||
'exercise_0_name': 'Shoulder Press',
|
||||
'exercise_0_set_count': '3',
|
||||
'exercise_0_set_0_reps': '10',
|
||||
'exercise_0_set_0_weight_lbs': '70',
|
||||
'exercise_0_set_1_reps': '10',
|
||||
'exercise_0_set_1_weight_lbs': '80',
|
||||
'exercise_0_set_2_reps': '8',
|
||||
'exercise_0_set_2_weight_lbs': '90',
|
||||
'exercise_1_name': 'Arnold Press',
|
||||
'exercise_1_set_count': '3',
|
||||
'exercise_1_set_0_reps': '10',
|
||||
'exercise_1_set_0_weight_lbs': '35',
|
||||
'exercise_1_set_1_reps': '10',
|
||||
'exercise_1_set_1_weight_lbs': '35',
|
||||
'exercise_1_set_2_reps': '8',
|
||||
'exercise_1_set_2_weight_lbs': '40',
|
||||
},
|
||||
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]['exercise_count'] == 2
|
||||
assert payload[0]['set_count'] == 6
|
||||
assert payload[0]['total_volume_lbs'] == 3240
|
||||
assert payload[0]['exercises'][0]['exercise_name'] == 'Shoulder Press'
|
||||
assert payload[0]['exercises'][0]['sets'][2] == {'reps': 8, 'weight_lbs': 90.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