22 lines
466 B
Python
22 lines
466 B
Python
import json
|
|||
|
|
|
||
|
|
import pytest
|
||
|
|
|
||
|
|
from hass.memory import ConversationMemory
|
||
|
|
|
||
|
|
|
||
|
|
@pytest.mark.asyncio
|
||
|
|
async def test_memory_persist_roundtrip(tmp_path):
|
||
|
|
path = tmp_path / "state.json"
|
||
|
|
m = ConversationMemory(str(path))
|
||
|
|
m.conversation_id = "abc"
|
||
|
|
await m.save()
|
||
|
|
|
||
|
|
raw = json.loads(path.read_text(encoding="utf-8"))
|
||
|
|
assert raw["conversation_id"] == "abc"
|
||
|
|
|
||
|
|
m2 = ConversationMemory(str(path))
|
||
|
|
await m2.load()
|
||
|
|
assert m2.conversation_id == "abc"
|
||
|
|
|