feat(matrix): add adapter baseline and platform-aware command hints
This commit is contained in:
parent
bcdaea5143
commit
82eb711844
20 changed files with 1127 additions and 3 deletions
72
tests/adapter/matrix/test_store.py
Normal file
72
tests/adapter/matrix/test_store.py
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
from adapter.matrix.store import (
|
||||
get_room_meta,
|
||||
get_room_state,
|
||||
get_skills_message_id,
|
||||
get_user_meta,
|
||||
next_chat_id,
|
||||
set_room_meta,
|
||||
set_room_state,
|
||||
set_skills_message_id,
|
||||
set_user_meta,
|
||||
)
|
||||
from core.store import InMemoryStore
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def store() -> InMemoryStore:
|
||||
return InMemoryStore()
|
||||
|
||||
|
||||
async def test_room_meta_roundtrip(store: InMemoryStore):
|
||||
meta = {
|
||||
"room_type": "chat",
|
||||
"chat_id": "C1",
|
||||
"display_name": "Чат 1",
|
||||
"matrix_user_id": "@alice:m.org",
|
||||
}
|
||||
await set_room_meta(store, "!r:m.org", meta)
|
||||
assert await get_room_meta(store, "!r:m.org") == meta
|
||||
|
||||
|
||||
async def test_room_meta_missing(store: InMemoryStore):
|
||||
assert await get_room_meta(store, "!nonexistent:m.org") is None
|
||||
|
||||
|
||||
async def test_user_meta_roundtrip(store: InMemoryStore):
|
||||
meta = {
|
||||
"platform_user_id": "usr-1",
|
||||
"display_name": "Alice",
|
||||
"space_id": None,
|
||||
"settings_room_id": None,
|
||||
"next_chat_index": 1,
|
||||
}
|
||||
await set_user_meta(store, "@alice:m.org", meta)
|
||||
assert await get_user_meta(store, "@alice:m.org") == meta
|
||||
|
||||
|
||||
async def test_room_state_roundtrip(store: InMemoryStore):
|
||||
await set_room_state(store, "!r:m.org", "idle")
|
||||
assert await get_room_state(store, "!r:m.org") == "idle"
|
||||
await set_room_state(store, "!r:m.org", "waiting_response")
|
||||
assert await get_room_state(store, "!r:m.org") == "waiting_response"
|
||||
|
||||
|
||||
async def test_room_state_default_idle(store: InMemoryStore):
|
||||
assert await get_room_state(store, "!unknown:m.org") == "idle"
|
||||
|
||||
|
||||
async def test_next_chat_id_increments(store: InMemoryStore):
|
||||
uid = "@alice:m.org"
|
||||
await set_user_meta(store, uid, {"next_chat_index": 1})
|
||||
assert await next_chat_id(store, uid) == "C1"
|
||||
assert await next_chat_id(store, uid) == "C2"
|
||||
assert await next_chat_id(store, uid) == "C3"
|
||||
|
||||
|
||||
async def test_skills_message_roundtrip(store: InMemoryStore):
|
||||
await set_skills_message_id(store, "!room", "$event")
|
||||
assert await get_skills_message_id(store, "!room") == "$event"
|
||||
Loading…
Add table
Add a link
Reference in a new issue