mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-05-14 19:05:27 +00:00
e63c403623
* docs: simplex-chat-python design and implementation plan * bots: Python wire types codegen * simplex-chat-python: package scaffold * simplex-chat-python: native libsimplex loader * simplex-chat-python: async FFI wrappers * simplex-chat-python: ChatApi with 49 api methods * simplex-chat-python: Bot class with decorators and dispatch * simplex-chat-python: install CLI, example bot, README * simplex-chat-python: audit fixes * bots: regenerate API docs and types Catches up the markdown, TypeScript and Python codegen outputs with two upstream schema changes: - APIConnectPlan.connectionLink became optional (from sh/python-lib audit fixes); cmdString and EBNF syntax now reflect optional parameter. - APIAddGroupRelays command and CRGroupRelaysAdded/CRGroupRelaysAddFailed responses added in #6917 (relay management). The TS and markdown outputs were regenerated when #6917 landed but the Python types module only got the new entries with this regeneration. * core: refresh SQLite query plans after relay_inactive_at migration The M20260507_relay_inactive_at migration (#6917 / #6952) shifted the query plans that 'Save query plans' verifies. Regenerated via the test that owns those snapshots; no behavioral change. * bots: keep APIConnectPlan connectionLink as required parameter The prior audit-fixes commit changed the syntax expression to `Optional ...` because the Haskell field is `connectionLink :: Maybe AConnectionLink`. That misrepresents the API contract: the `Maybe` is purely an internal signal for link-parsing failure (the handler returns `CEInvalidConnReq` on `Nothing`), not API-level optionality. Callers MUST always pass a connection link. Revert the syntax expression to `Param "connectionLink"` and add a comment so the intent is preserved next time someone audits. Regenerates COMMANDS.md, commands.ts and _commands.py to match.
42 lines
1.3 KiB
Python
42 lines
1.3 KiB
Python
"""Sanity checks on auto-generated wire types — catches generator regressions."""
|
|
|
|
import typing
|
|
|
|
from simplex_chat.types import CC, CEvt, CR, T
|
|
|
|
|
|
def test_types_module_imports():
|
|
"""Every generated module imports cleanly with no SyntaxError."""
|
|
assert T is not None and CC is not None and CR is not None and CEvt is not None
|
|
|
|
|
|
def test_chat_type_is_literal_enum():
|
|
"""ChatType should be a Literal of expected member set."""
|
|
args = typing.get_args(T.ChatType)
|
|
assert "direct" in args
|
|
assert "group" in args
|
|
assert "local" in args
|
|
|
|
|
|
def test_known_command_has_cmd_string():
|
|
s = CC.APICreateMyAddress_cmd_string({"userId": 1})
|
|
assert s == "/_address 1"
|
|
|
|
|
|
def test_chat_response_tag_alias_present():
|
|
"""ChatResponse_Tag union of literals exists."""
|
|
assert hasattr(CR, "ChatResponse_Tag")
|
|
|
|
|
|
def test_chat_event_tag_alias_present():
|
|
"""ChatEvent_Tag exists; covers the on_event Literal annotation."""
|
|
assert hasattr(CEvt, "ChatEvent_Tag")
|
|
args = typing.get_args(CEvt.ChatEvent_Tag)
|
|
assert "newChatItems" in args
|
|
|
|
|
|
def test_chat_ref_cmd_string_direct():
|
|
"""Sanity check the codegen fix for ChatRef-bearing commands."""
|
|
assert T.ChatRef_cmd_string({"chatType": "direct", "chatId": 7}) == "@7"
|
|
assert T.ChatRef_cmd_string({"chatType": "group", "chatId": 42}) == "#42"
|