feat: Matrix connector core — rooms, messaging, sync

- rooms: create, join, leave, forget, list, resolve alias, get info/members,
  invite/kick/ban/unban, set name/topic. RoomInfo/MemberInfo/PowerLevels dataclasses.
- messaging: send text (with HTML, reply, thread), notice, emote, image, file,
  sticker, edit, redact, react, typing, read receipts, fully-read markers.
- sync: SyncEngine with event-type/room/global handler dispatch,
  incremental sync with backoff retry, SyncFilter, paginated message history.
- CLI: rooms (list/create/join/leave/info/members/invite), send (text/image/file),
  sync (listen with filters).
- 182 tests pass (60 existing + 122 new).
This commit is contained in:
2026-05-23 12:07:10 -04:00
parent 7423d3bd17
commit 3ddf8170f8
9 changed files with 3350 additions and 4 deletions
+97
View File
@@ -203,3 +203,100 @@ class TestCmdLogout:
args = build_parser().parse_args(["logout"])
result = cmd_logout(args)
assert result == 0
# ---------------------------------------------------------------------------
# New async command parser tests
# ---------------------------------------------------------------------------
class TestNewCommandsParser:
"""Tests for parser entries of rooms, send, sync commands."""
def test_rooms_subparser_exists(self):
parser = build_parser()
choices = parser._subparsers._group_actions[0].choices
assert "rooms" in choices
assert "send" in choices
assert "sync" in choices
def test_rooms_list(self):
args = build_parser().parse_args(["rooms", "list"])
assert args.command == "rooms"
assert args.rooms_action == "list"
def test_rooms_create(self):
args = build_parser().parse_args(
["rooms", "create", "--name", "Test", "--topic", "Hello", "--public"]
)
assert args.rooms_action == "create"
assert args.name == "Test"
assert args.topic == "Hello"
assert args.public is True
def test_rooms_join(self):
args = build_parser().parse_args(["rooms", "join", "!room:example.org"])
assert args.rooms_action == "join"
assert args.room == "!room:example.org"
def test_rooms_leave(self):
args = build_parser().parse_args(["rooms", "leave", "!room:example.org"])
assert args.rooms_action == "leave"
assert args.room == "!room:example.org"
def test_rooms_info(self):
args = build_parser().parse_args(["rooms", "info", "!room:example.org"])
assert args.rooms_action == "info"
assert args.room == "!room:example.org"
def test_rooms_members(self):
args = build_parser().parse_args(["rooms", "members", "!room:example.org"])
assert args.rooms_action == "members"
def test_rooms_invite(self):
args = build_parser().parse_args(
["rooms", "invite", "!room:example.org", "@alice:example.org"]
)
assert args.rooms_action == "invite"
assert args.user == "@alice:example.org"
def test_send_text(self):
args = build_parser().parse_args(["send", "text", "!room:example.org", "Hello world"])
assert args.send_action == "text"
assert args.room == "!room:example.org"
assert args.body == "Hello world"
def test_send_text_with_reply(self):
args = build_parser().parse_args(
["send", "text", "!room:example.org", "Replying", "--reply-to", "$evt:example.org"]
)
assert args.reply_to == "$evt:example.org"
def test_send_image(self):
args = build_parser().parse_args(
["send", "image", "!room:example.org", "/tmp/photo.jpg", "--caption", "My photo"]
)
assert args.send_action == "image"
assert args.path == "/tmp/photo.jpg"
assert args.caption == "My photo"
def test_send_file(self):
args = build_parser().parse_args(
["send", "file", "!room:example.org", "/tmp/doc.pdf"]
)
assert args.send_action == "file"
def test_sync_listen(self):
args = build_parser().parse_args(["sync", "listen"])
assert args.sync_action == "listen"
assert args.filter_type == []
assert args.room == []
assert args.show_all is False
def test_sync_listen_with_filters(self):
args = build_parser().parse_args(
["sync", "listen", "--filter-type", "m.room.message", "--room", "!test:example.org", "--show-all"]
)
assert args.filter_type == ["m.room.message"]
assert args.room == ["!test:example.org"]
assert args.show_all is True