shinkan-jinkendo/backend/tests/test_planning_exercise_suggest_variants.py
Lars a34e748be5
All checks were successful
Deploy Development / deploy (push) Successful in 44s
Test Suite / pytest-backend (push) Successful in 40s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 18s
Test Suite / k6 /health Baseline (push) Successful in 33s
Test Suite / playwright-tests (push) Successful in 1m14s
Test Suite / pytest-backend (pull_request) Successful in 38s
Test Suite / lint-backend (pull_request) Successful in 0s
Test Suite / build-frontend (pull_request) Successful in 13s
Test Suite / k6 /health Baseline (pull_request) Successful in 33s
Test Suite / playwright-tests (pull_request) Successful in 1m13s
Implement Phase C2 Enhancements for Exercise Suggestions
- Incremented version to 0.8.184, reflecting the implementation of Phase C2 features.
- Added support for displaying variant lists and suggested variant names in exercise suggestions.
- Enhanced the ExercisePickerModal to allow selection of exercise variants and improved handling of variant IDs.
- Updated backend logic to enrich planning hits with variant metadata, ensuring accurate exercise variant selection.
- Documented changes in the changelog to highlight the new capabilities in planning AI functionality.
2026-05-23 11:39:18 +02:00

44 lines
1.3 KiB
Python

"""Tests Phase C2: Varianten-Metadaten in Planungs-Treffern."""
from planning_exercise_suggest import _enrich_planning_hits_with_variant_meta
class _Cur:
def __init__(self, rows):
self._rows = rows
self.last_query = ''
def execute(self, query, params=None):
self.last_query = query
self._params = params
def fetchall(self):
q = self.last_query
if 'FROM exercise_variants WHERE id IN' in q:
return [
{'id': 7, 'variant_name': 'Leicht'},
]
if 'FROM exercise_variants' in q and 'exercise_id IN' in q:
return [
{
'exercise_id': 10,
'id': 7,
'variant_name': 'Leicht',
'sequence_order': 1,
},
{
'exercise_id': 10,
'id': 8,
'variant_name': 'Schwer',
'sequence_order': 2,
},
]
return []
def test_enrich_planning_hits_with_variant_meta():
hits = [{'id': 10, 'title': 'Test', 'suggested_variant_id': 7}]
out = _enrich_planning_hits_with_variant_meta(_Cur([]), hits)
assert out[0]['suggested_variant_name'] == 'Leicht'
assert len(out[0]['variants']) == 2
assert out[0]['variants'][0]['id'] == 7