24 lines
790 B
Python
24 lines
790 B
Python
"""Regression coverage for session persistence on the mounted data directory."""
|
|
|
|
from google.genai import types
|
|
|
|
from homeagent.agent.conversation import ConversationManager
|
|
|
|
|
|
def test_conversation_file_survives_restart_and_is_atomic(tmp_path):
|
|
manager = ConversationManager(tmp_path, max_turns=5)
|
|
manager.append_content(
|
|
42,
|
|
None,
|
|
types.Content(role="user", parts=[types.Part.from_text(text="persist me")]),
|
|
)
|
|
|
|
session_file = tmp_path / "sessions" / "session_42_main.json"
|
|
assert session_file.exists()
|
|
assert not list(session_file.parent.glob("*.tmp"))
|
|
|
|
restarted = ConversationManager(tmp_path, max_turns=5)
|
|
history = restarted.get_history(42, None)
|
|
assert len(history) == 1
|
|
assert history[0].parts[0].text == "persist me"
|