2026-08-24 22:23:57 +02:00
|
|
|
from tamq import control
|
|
|
|
|
from tamq.control import ControlModeClient, shell_quote
|
2026-08-24 01:18:40 +02:00
|
|
|
from tamq.tmux import shell_join
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_shell_quote():
|
|
|
|
|
quoted = shell_quote("hello 'world'")
|
|
|
|
|
assert quoted.startswith("'") and quoted.endswith("'")
|
|
|
|
|
assert "\\'" in quoted
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_tmux_shell_join_quotes_arguments():
|
|
|
|
|
assert shell_join(["tamq", "tap", "--repo", "net-kingdom", "--", "codex"]) == "tamq tap --repo net-kingdom -- codex"
|
2026-08-24 22:23:57 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_pane_tty_is_resolved_through_tmux(monkeypatch):
|
|
|
|
|
calls = []
|
|
|
|
|
|
|
|
|
|
def run(command, **kwargs):
|
|
|
|
|
calls.append(command)
|
2026-08-24 23:03:30 +02:00
|
|
|
return type("Result", (), {"returncode": 0, "stdout": "/dev/pts/7|12|8|24|0\n", "stderr": ""})()
|
2026-08-24 22:23:57 +02:00
|
|
|
|
|
|
|
|
monkeypatch.setattr(control.subprocess, "run", run)
|
|
|
|
|
client = ControlModeClient("tamq", tmux_command=("tmux", "-L", "test"))
|
|
|
|
|
assert client.pane_tty("tamq:audit-core") == "/dev/pts/7"
|
|
|
|
|
assert calls == [[
|
|
|
|
|
"tmux", "-L", "test", "display-message", "-p", "-t",
|
2026-08-24 23:03:30 +02:00
|
|
|
"tamq:audit-core", "#{pane_tty}|#{cursor_x}|#{cursor_y}|#{pane_height}|#{alternate_on}",
|
2026-08-24 22:23:57 +02:00
|
|
|
]]
|