test: improve deterministic unit test coverage

This commit is contained in:
chengyongru
2026-06-04 19:41:32 +08:00
committed by Xubin Ren
parent 87bd56468c
commit 24e56fcf07
27 changed files with 279 additions and 213 deletions
+5 -2
View File
@@ -1,10 +1,11 @@
"""Test session management with cache-friendly message handling."""
import asyncio
from pathlib import Path
from unittest.mock import AsyncMock, MagicMock
import pytest
from pathlib import Path
from nanobot.session.manager import Session, SessionManager
# Test constants
@@ -603,9 +604,10 @@ class TestNewCommandArchival:
loop.sessions.save(session)
archived = asyncio.Event()
release_archive = asyncio.Event()
async def _slow_summarize(_messages) -> bool:
await asyncio.sleep(0.1)
await release_archive.wait()
archived.set()
return True
@@ -615,5 +617,6 @@ class TestNewCommandArchival:
await loop._process_message(new_msg)
assert not archived.is_set()
release_archive.set()
await loop.close_mcp()
assert archived.is_set()