All checks were successful
Deploy Development / deploy (push) Successful in 43s
Test Suite / pytest-backend (push) Successful in 44s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 13s
Test Suite / k6 /health Baseline (push) Successful in 41s
Test Suite / playwright-tests (push) Successful in 1m21s
- Added a new function `_graph_promotion_transition` to determine the necessary exercise visibility changes during graph promotions. - Updated the `list_visibility_promotion_candidates` endpoint to utilize the new promotion logic, ensuring accurate exercise visibility handling. - Enhanced the frontend components to prompt users for exercise visibility adjustments based on graph visibility changes, improving user experience. - Introduced tests for the new promotion logic to ensure correctness and reliability in visibility transitions.
81 lines
2.5 KiB
Python
81 lines
2.5 KiB
Python
"""Sichtbarkeit: Progressionsgraph ↔ Übungen (Promotion, Kanten, Match)."""
|
|
from routers.exercise_progression_graphs import (
|
|
_exercise_allowed_in_progression_graph,
|
|
_graph_promotion_transition,
|
|
)
|
|
|
|
|
|
def test_graph_promotion_transition_private_to_club():
|
|
assert _graph_promotion_transition("private", "club") == ("private",)
|
|
|
|
|
|
def test_graph_promotion_transition_private_to_official():
|
|
assert _graph_promotion_transition("private", "official") == ("private", "club")
|
|
|
|
|
|
def test_graph_promotion_transition_club_to_official():
|
|
assert _graph_promotion_transition("club", "official") == ("private", "club")
|
|
|
|
|
|
def test_graph_promotion_transition_noop():
|
|
assert _graph_promotion_transition("club", "club") is None
|
|
assert _graph_promotion_transition("official", "club") is None
|
|
assert _graph_promotion_transition("private", "private") is None
|
|
|
|
|
|
def test_club_graph_rejects_private_exercise():
|
|
assert not _exercise_allowed_in_progression_graph(
|
|
{"visibility": "private", "club_id": None, "created_by": 1},
|
|
graph_visibility="club",
|
|
graph_club_id=5,
|
|
profile_id=1,
|
|
role="trainer",
|
|
)
|
|
|
|
|
|
def test_club_graph_accepts_matching_club_exercise():
|
|
assert _exercise_allowed_in_progression_graph(
|
|
{"visibility": "club", "club_id": 5, "created_by": 2},
|
|
graph_visibility="club",
|
|
graph_club_id=5,
|
|
profile_id=1,
|
|
role="trainer",
|
|
)
|
|
|
|
|
|
def test_club_graph_accepts_official_exercise():
|
|
assert _exercise_allowed_in_progression_graph(
|
|
{"visibility": "official", "club_id": None, "created_by": 99},
|
|
graph_visibility="club",
|
|
graph_club_id=5,
|
|
profile_id=1,
|
|
role="trainer",
|
|
)
|
|
|
|
|
|
def test_private_graph_accepts_own_private_exercise():
|
|
assert _exercise_allowed_in_progression_graph(
|
|
{"visibility": "private", "club_id": None, "created_by": 7},
|
|
graph_visibility="private",
|
|
graph_club_id=None,
|
|
profile_id=7,
|
|
role="trainer",
|
|
)
|
|
|
|
|
|
def test_official_graph_requires_official_exercise():
|
|
assert not _exercise_allowed_in_progression_graph(
|
|
{"visibility": "club", "club_id": 5, "created_by": 2},
|
|
graph_visibility="official",
|
|
graph_club_id=None,
|
|
profile_id=1,
|
|
role="trainer",
|
|
)
|
|
assert _exercise_allowed_in_progression_graph(
|
|
{"visibility": "official", "club_id": None, "created_by": 2},
|
|
graph_visibility="official",
|
|
graph_club_id=None,
|
|
profile_id=1,
|
|
role="trainer",
|
|
)
|