feat(04-02): extend prototype and matrix pending state
- add saved session and last token tracking in prototype state - add matrix load/reset pending store helpers
This commit is contained in:
parent
6923b801a3
commit
2720ee2d6e
3 changed files with 97 additions and 0 deletions
|
|
@ -89,3 +89,46 @@ async def test_update_settings_supports_toggle_skill_and_setters():
|
|||
assert settings.skills["web-search"] is True
|
||||
assert settings.soul["instructions"] == "Be concise"
|
||||
assert settings.safety["social-post"] is False
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_add_saved_session_appends_named_entries():
|
||||
store = PrototypeStateStore()
|
||||
|
||||
await store.add_saved_session("usr-matrix-@alice:example.org", "alpha")
|
||||
await store.add_saved_session("usr-matrix-@alice:example.org", "beta")
|
||||
|
||||
sessions = await store.list_saved_sessions("usr-matrix-@alice:example.org")
|
||||
|
||||
assert [session["name"] for session in sessions] == ["alpha", "beta"]
|
||||
assert all("created_at" in session for session in sessions)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_list_saved_sessions_returns_copy():
|
||||
store = PrototypeStateStore()
|
||||
|
||||
await store.add_saved_session("usr-matrix-@alice:example.org", "alpha")
|
||||
|
||||
sessions = await store.list_saved_sessions("usr-matrix-@alice:example.org")
|
||||
sessions.append({"name": "tampered", "created_at": "never"})
|
||||
|
||||
stored = await store.list_saved_sessions("usr-matrix-@alice:example.org")
|
||||
|
||||
assert [session["name"] for session in stored] == ["alpha"]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_last_tokens_used_defaults_to_zero():
|
||||
store = PrototypeStateStore()
|
||||
|
||||
assert await store.get_last_tokens_used("usr-matrix-@alice:example.org") == 0
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_set_last_tokens_used_persists_value():
|
||||
store = PrototypeStateStore()
|
||||
|
||||
await store.set_last_tokens_used("usr-matrix-@alice:example.org", 321)
|
||||
|
||||
assert await store.get_last_tokens_used("usr-matrix-@alice:example.org") == 321
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue