mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-06-10 09:25:57 +00:00
fix: load paginated run history messages (#3305)
This commit is contained in:
@@ -6,6 +6,7 @@ import asyncio
|
||||
from unittest.mock import AsyncMock, MagicMock
|
||||
|
||||
from _router_auth_helpers import make_authed_test_app
|
||||
from _run_message_pagination_helpers import assert_run_message_page
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from app.gateway.routers import thread_runs
|
||||
@@ -88,6 +89,43 @@ def test_has_more_true_when_extra_row_returned():
|
||||
body = response.json()
|
||||
assert body["has_more"] is True
|
||||
assert len(body["data"]) == 50 # trimmed to limit
|
||||
assert [m["seq"] for m in body["data"]] == list(range(2, 52))
|
||||
|
||||
|
||||
def test_default_page_keeps_newest_messages_when_extra_row_returned():
|
||||
"""Default latest-page trimming drops the older sentinel row, not the newest message."""
|
||||
rows = [_make_message(i) for i in range(16, 67)]
|
||||
app = _make_app(event_store=_make_event_store(rows))
|
||||
with TestClient(app) as client:
|
||||
assert_run_message_page(
|
||||
client,
|
||||
"/api/threads/thread-2/runs/run-2/messages",
|
||||
expected_seq=list(range(17, 67)),
|
||||
)
|
||||
|
||||
|
||||
def test_before_seq_page_keeps_newest_side_when_extra_row_returned():
|
||||
"""Backward pagination trims the older sentinel so adjacent pages do not miss the boundary message."""
|
||||
rows = [_make_message(i) for i in range(1, 18)]
|
||||
app = _make_app(event_store=_make_event_store(rows))
|
||||
with TestClient(app) as client:
|
||||
assert_run_message_page(
|
||||
client,
|
||||
"/api/threads/thread-2/runs/run-2/messages?before_seq=18&limit=16",
|
||||
expected_seq=list(range(2, 18)),
|
||||
)
|
||||
|
||||
|
||||
def test_after_seq_page_keeps_oldest_side_when_extra_row_returned():
|
||||
"""Forward pagination still trims the newer sentinel row."""
|
||||
rows = [_make_message(i) for i in range(11, 62)]
|
||||
app = _make_app(event_store=_make_event_store(rows))
|
||||
with TestClient(app) as client:
|
||||
assert_run_message_page(
|
||||
client,
|
||||
"/api/threads/thread-2/runs/run-2/messages?after_seq=10",
|
||||
expected_seq=list(range(11, 61)),
|
||||
)
|
||||
|
||||
|
||||
def test_after_seq_forwarded_to_event_store():
|
||||
|
||||
Reference in New Issue
Block a user