mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-08-27 22:34:51 +00:00
* feat: add simplex-support-bot-light * feat: package simplex-support-bot-light for docker * docs: document simplex-support-bot-light * fix: make a missing config actionable and bounded * docs: note the attached compose Ctrl+C behaviour * refactor: use the library for startup and custom data * refactor: drop the display-name workaround * style: shorten the startup comment * build: build the core and the library into the image * docs: correct where the image type rule comes from * fix: log what the core said a command got wrong * build: run the container as the operator's uid * docs: keep the container uid in .env * docs: tighten the README
33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
from simplex_chat import BotCommand
|
|
|
|
from support_bot_light.commands import COMMANDS, to_wire
|
|
|
|
|
|
def test_declares_four_commands():
|
|
assert tuple(c.keyword for c in COMMANDS) == ("dm", "list", "leave", "help")
|
|
|
|
|
|
def test_no_command_takes_params():
|
|
# Zero-argument commands send on tap instead of pasting a placeholder.
|
|
assert all(c.params is None for c in COMMANDS)
|
|
|
|
|
|
def test_to_wire_omits_params_when_none():
|
|
wire = to_wire([BotCommand(keyword="list", label="Who gets invited")])
|
|
assert wire == [{"type": "command", "keyword": "list", "label": "Who gets invited"}]
|
|
assert "params" not in wire[0]
|
|
|
|
|
|
def test_to_wire_includes_params_when_set():
|
|
wire = to_wire([BotCommand(keyword="x", label="X", params="<n>")])
|
|
assert wire == [{"type": "command", "keyword": "x", "label": "X", "params": "<n>"}]
|
|
|
|
|
|
def test_to_wire_distinguishes_none_from_empty_string():
|
|
assert "params" not in to_wire([BotCommand("a", "A")])[0]
|
|
assert to_wire([BotCommand("b", "B", params="")])[0]["params"] == ""
|
|
|
|
|
|
def test_to_wire_preserves_declaration_order():
|
|
assert [c["keyword"] for c in to_wire(COMMANDS)] == [c.keyword for c in COMMANDS]
|