44 lines
1.3 KiB
Python
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
|