test_ctl.py 867 B

123456789101112131415161718192021222324252627282930313233
  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. ("status", "status"),
  13. ],
  14. )
  15. def test_build_message_maps_verbs(verb, expected):
  16. assert build_message(verb) == {"type": expected}
  17. def test_build_message_includes_text_only_when_given():
  18. assert build_message("command-edit", "hello") == {
  19. "type": "command_edit",
  20. "text": "hello",
  21. }
  22. assert "text" not in build_message("command-start")
  23. def test_build_message_rejects_unknown():
  24. with pytest.raises(ValueError):
  25. build_message("nope")