feat: persist single evaluation history

This commit is contained in:
wuyang6
2026-07-23 19:46:15 +08:00
parent 5be9434ba3
commit 6116d10e8f
5 changed files with 398 additions and 13 deletions
+39
View File
@@ -88,6 +88,45 @@ class EvaluationApiTests(unittest.TestCase):
self.assertEqual(response.json()['prediction'], '地图导航')
analyze.assert_called_once()
def test_single_analysis_history_endpoints(self) -> None:
with tempfile.TemporaryDirectory() as directory:
root = Path(directory)
state = _build_state(root)
record = {
'id': 'single_1',
'query': '导航去公司',
'prediction': '地图导航',
'status': 'completed',
}
with (
TestClient(create_app(state)) as client,
patch.object(
state.evaluation_runtime,
'list_single_analyses',
return_value=[record],
) as list_history,
patch.object(
state.evaluation_runtime,
'get_single_analysis',
return_value=record,
) as get_history,
):
response = client.get(
'/api/evaluations/analyses',
params={'account_id': 'alice'},
)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.json(), [record])
list_history.assert_called_once_with('alice')
detail = client.get(
'/api/evaluations/analyses/single_1',
params={'account_id': 'alice'},
)
self.assertEqual(detail.status_code, 200)
self.assertEqual(detail.json(), record)
get_history.assert_called_once_with('single_1', 'alice')
def test_dataset_experiment_and_export_flow(self) -> None:
with tempfile.TemporaryDirectory() as directory:
root = Path(directory)