feat: finalize matrix platform audit and docs
This commit is contained in:
parent
6422c7db58
commit
4524a6abc8
30 changed files with 3093 additions and 176 deletions
|
|
@ -6,7 +6,11 @@ from unittest.mock import AsyncMock
|
|||
from nio.api import RoomVisibility
|
||||
from nio.responses import RoomCreateError
|
||||
|
||||
from adapter.matrix.handlers.chat import make_handle_archive, make_handle_new_chat, make_handle_rename
|
||||
from adapter.matrix.handlers.chat import (
|
||||
make_handle_archive,
|
||||
make_handle_new_chat,
|
||||
make_handle_rename,
|
||||
)
|
||||
from adapter.matrix.store import get_room_meta, set_user_meta
|
||||
from core.auth import AuthManager
|
||||
from core.chat import ChatManager
|
||||
|
|
@ -28,7 +32,9 @@ async def _setup():
|
|||
|
||||
async def test_mat04_new_chat_calls_room_put_state_with_space_id():
|
||||
platform, store, chat_mgr, auth_mgr, settings_mgr = await _setup()
|
||||
await set_user_meta(store, "@alice:example.org", {"space_id": "!space:ex", "next_chat_index": 2})
|
||||
await set_user_meta(
|
||||
store, "@alice:example.org", {"space_id": "!space:ex", "next_chat_index": 2}
|
||||
)
|
||||
|
||||
client = SimpleNamespace(
|
||||
room_create=AsyncMock(return_value=SimpleNamespace(room_id="!newroom:ex")),
|
||||
|
|
@ -59,7 +65,7 @@ async def test_mat04_new_chat_calls_room_put_state_with_space_id():
|
|||
assert kwargs.get("state_key") == "!newroom:ex"
|
||||
room_meta = await get_room_meta(store, "!newroom:ex")
|
||||
assert room_meta is not None
|
||||
assert room_meta["platform_chat_id"] == "matrix:!newroom:ex"
|
||||
assert room_meta["platform_chat_id"] == "1"
|
||||
assert any(isinstance(item, OutgoingMessage) and "Test" in item.text for item in result)
|
||||
|
||||
|
||||
|
|
@ -169,10 +175,14 @@ async def test_mat11b_rename_from_unregistered_room_returns_error_message():
|
|||
|
||||
async def test_mat12_room_create_error_returns_user_message():
|
||||
platform, store, chat_mgr, auth_mgr, settings_mgr = await _setup()
|
||||
await set_user_meta(store, "@alice:example.org", {"space_id": "!space:ex", "next_chat_index": 2})
|
||||
await set_user_meta(
|
||||
store, "@alice:example.org", {"space_id": "!space:ex", "next_chat_index": 2}
|
||||
)
|
||||
|
||||
client = SimpleNamespace(
|
||||
room_create=AsyncMock(return_value=RoomCreateError(message="rate limited", status_code="429")),
|
||||
room_create=AsyncMock(
|
||||
return_value=RoomCreateError(message="rate limited", status_code="429")
|
||||
),
|
||||
room_put_state=AsyncMock(),
|
||||
room_invite=AsyncMock(),
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue