test_ctl.py 903 B

12345678910111213141516171819202122232425262728293031323334
  1. """Tests for the stt-ctl command mapping."""
  2. import pytest
  3. from stt_daemon.ctl import build_message
  4. @pytest.mark.parametrize(
  5. ("verb", "expected"),
  6. [
  7. ("command-start", "command_start"),
  8. ("command-execute", "command_execute"),
  9. ("command-cancel", "command_cancel"),
  10. ("command-edit", "command_edit"),
  11. ("chat-toggle", "chat_toggle"),
  12. ("chat-send", "chat_send"),
  13. ("status", "status"),
  14. ],
  15. )
  16. def test_build_message_maps_verbs(verb, expected):
  17. assert build_message(verb) == {"type": expected}
  18. def test_build_message_includes_text_only_when_given():
  19. assert build_message("command-edit", "hello") == {
  20. "type": "command_edit",
  21. "text": "hello",
  22. }
  23. assert "text" not in build_message("command-start")
  24. def test_build_message_rejects_unknown():
  25. with pytest.raises(ValueError):
  26. build_message("nope")