From ddd999c938973878062698ed2172e4695ce5eda9 Mon Sep 17 00:00:00 2001 From: Barsic <16+barsic@noreply.localhost> Date: Fri, 13 Nov 2026 22:01:55 +0300 Subject: [PATCH] test: cover durable conversation files after restart --- tests/test_persistent_conversation.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tests/test_persistent_conversation.py diff --git a/tests/test_persistent_conversation.py b/tests/test_persistent_conversation.py new file mode 100644 index 0000000..108e51e --- /dev/null +++ b/tests/test_persistent_conversation.py @@ -0,0 +1,23 @@ +"""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"