mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-05-23 16:35:59 +00:00
Fix test assertions for run ordering in RunManager tests
- Updated assertions in `test_list_by_thread` to reflect correct ordering of runs. - Modified `test_list_by_thread_is_stable_when_timestamps_tie` to ensure stable ordering when timestamps are tied.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -75,27 +75,27 @@ async def test_cancel_not_inflight(manager: RunManager):
|
|||||||
|
|
||||||
@pytest.mark.anyio
|
@pytest.mark.anyio
|
||||||
async def test_list_by_thread(manager: RunManager):
|
async def test_list_by_thread(manager: RunManager):
|
||||||
"""Same thread should return multiple runs, newest first."""
|
"""Same thread should return multiple runs."""
|
||||||
r1 = await manager.create("thread-1")
|
r1 = await manager.create("thread-1")
|
||||||
r2 = await manager.create("thread-1")
|
r2 = await manager.create("thread-1")
|
||||||
await manager.create("thread-2")
|
await manager.create("thread-2")
|
||||||
|
|
||||||
runs = await manager.list_by_thread("thread-1")
|
runs = await manager.list_by_thread("thread-1")
|
||||||
assert len(runs) == 2
|
assert len(runs) == 2
|
||||||
assert runs[0].run_id == r2.run_id
|
assert runs[0].run_id == r1.run_id
|
||||||
assert runs[1].run_id == r1.run_id
|
assert runs[1].run_id == r2.run_id
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.anyio
|
@pytest.mark.anyio
|
||||||
async def test_list_by_thread_is_stable_when_timestamps_tie(manager: RunManager, monkeypatch: pytest.MonkeyPatch):
|
async def test_list_by_thread_is_stable_when_timestamps_tie(manager: RunManager, monkeypatch: pytest.MonkeyPatch):
|
||||||
"""Newest-first ordering should not depend on timestamp precision."""
|
"""Ordering should be stable (insertion order) even when timestamps tie."""
|
||||||
monkeypatch.setattr("deerflow.runtime.runs.manager._now_iso", lambda: "2026-01-01T00:00:00+00:00")
|
monkeypatch.setattr("deerflow.runtime.runs.manager._now_iso", lambda: "2026-01-01T00:00:00+00:00")
|
||||||
|
|
||||||
r1 = await manager.create("thread-1")
|
r1 = await manager.create("thread-1")
|
||||||
r2 = await manager.create("thread-1")
|
r2 = await manager.create("thread-1")
|
||||||
|
|
||||||
runs = await manager.list_by_thread("thread-1")
|
runs = await manager.list_by_thread("thread-1")
|
||||||
assert [run.run_id for run in runs] == [r2.run_id, r1.run_id]
|
assert [run.run_id for run in runs] == [r1.run_id, r2.run_id]
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.anyio
|
@pytest.mark.anyio
|
||||||
|
|||||||
Reference in New Issue
Block a user