All checks were successful
Deploy Development / deploy (push) Successful in 39s
Test Suite / pytest-backend (push) Successful in 36s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 12s
Test Suite / k6 /health Baseline (push) Successful in 33s
Test Suite / playwright-tests (push) Successful in 1m9s
- Updated the backend to improve the fetching and insertion of training unit sections, including a new function for handling section items. - Added documentation notes regarding the unique constraint on `training_unit_sections` and the implications for parallel training streams. - Updated frontend components and utility functions to reflect changes in the training planning API and to prepare for future enhancements related to parallel streams.
33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
"""Unit-Tests ohne DB: abgeleitete Trainingseinheit-Payload-Helfer."""
|
|
import pytest
|
|
|
|
from routers.training_planning import _flatten_exercises_from_sections
|
|
|
|
|
|
def test_flatten_exercises_from_sections_order():
|
|
unit = {
|
|
"sections": [
|
|
{
|
|
"order_index": 1,
|
|
"items": [
|
|
{"order_index": 1, "item_type": "exercise", "exercise_id": 10},
|
|
{"order_index": 0, "item_type": "note"},
|
|
{"order_index": 2, "item_type": "exercise", "exercise_id": 20},
|
|
],
|
|
},
|
|
{
|
|
"order_index": 0,
|
|
"items": [{"order_index": 0, "item_type": "exercise", "exercise_id": 5}],
|
|
},
|
|
]
|
|
}
|
|
_flatten_exercises_from_sections(unit)
|
|
# Sektionen nach order_index; innerhalb nur exercise-Items nach order_index
|
|
assert [x["exercise_id"] for x in unit["exercises"]] == [5, 10, 20]
|
|
|
|
|
|
def test_flatten_exercises_from_sections_empty():
|
|
unit = {"sections": []}
|
|
_flatten_exercises_from_sections(unit)
|
|
assert unit["exercises"] == []
|