test(agent): fix flaky test_keeps_n_most_recent by ensuring sequential mtimes
This commit is contained in:
@@ -24,9 +24,14 @@ class TestDreamSessionKey:
|
|||||||
|
|
||||||
class TestPruneDreamSessions:
|
class TestPruneDreamSessions:
|
||||||
def test_keeps_n_most_recent(self, tmp_path):
|
def test_keeps_n_most_recent(self, tmp_path):
|
||||||
|
import os
|
||||||
|
import time
|
||||||
|
|
||||||
sessions_dir = tmp_path / "sessions"
|
sessions_dir = tmp_path / "sessions"
|
||||||
sessions_dir.mkdir()
|
sessions_dir.mkdir()
|
||||||
|
|
||||||
|
base_time = time.time() - 100
|
||||||
|
|
||||||
for i in range(15):
|
for i in range(15):
|
||||||
key = f"dream:20260528-{100000 + i:06d}"
|
key = f"dream:20260528-{100000 + i:06d}"
|
||||||
safe_key = key.replace(":", "_")
|
safe_key = key.replace(":", "_")
|
||||||
@@ -37,6 +42,7 @@ class TestPruneDreamSessions:
|
|||||||
f'"updated_at": "2026-05-28T10:00:{i:02d}"}}\n',
|
f'"updated_at": "2026-05-28T10:00:{i:02d}"}}\n',
|
||||||
encoding="utf-8",
|
encoding="utf-8",
|
||||||
)
|
)
|
||||||
|
os.utime(path, (base_time + i, base_time + i))
|
||||||
|
|
||||||
normal_path = sessions_dir / "telegram_123.jsonl"
|
normal_path = sessions_dir / "telegram_123.jsonl"
|
||||||
normal_path.write_text('{"_type": "metadata"}\n', encoding="utf-8")
|
normal_path.write_text('{"_type": "metadata"}\n', encoding="utf-8")
|
||||||
|
|||||||
Reference in New Issue
Block a user