Assistant: codex Assistant-Model: gpt-5.6-sol Assistant-Session: 01a03397-4d51-7fd1-8ff2-946eb22ea2bc
This commit is contained in:
parent
788eb8e2ed
commit
92881b6b56
35 changed files with 1206 additions and 806 deletions
|
|
@ -6,55 +6,48 @@ import pytest
|
|||
|
||||
from tamq.terminal import (
|
||||
TerminalOutputError,
|
||||
format_comment,
|
||||
format_pushy_input,
|
||||
format_delivery,
|
||||
terminal_frame,
|
||||
write_terminal_output,
|
||||
)
|
||||
|
||||
|
||||
def test_comment_format_escapes_controls_and_prefixes_every_line():
|
||||
assert format_comment("repo-a", "first\nsecond\x1b[31m", "m-1") == (
|
||||
"#repo-a: first\n# second\\x1b[31m [m-1]"
|
||||
def test_delivery_format_escapes_controls_and_marks_operator_origin():
|
||||
assert format_delivery("repo-a", "first\nsecond\x1b[31m", "operator_input") == (
|
||||
"From:repo-a/o: first\\x0asecond\\x1b[31m"
|
||||
)
|
||||
|
||||
|
||||
def test_pushy_input_is_one_sanitized_shell_comment():
|
||||
assert format_pushy_input("repo-a", "first\nsecond\x1b[31m", "m-1") == (
|
||||
"# from repo-a: first\\x0asecond\\x1b[31m [m-1]"
|
||||
assert format_delivery("repo-a", "worker", "worker_output") == (
|
||||
"From:repo-a: worker"
|
||||
)
|
||||
|
||||
|
||||
def test_terminal_frame_scrolls_only_rows_above_the_cursor():
|
||||
assert terminal_frame(
|
||||
"repo-a", "first\nsecond", "m-1", cursor_y=8, pane_height=24
|
||||
"repo-a", "hello", "operator_input", cursor_y=8, pane_height=24
|
||||
) == (
|
||||
"\x1b7\x1b[1;8r\x1b[8;1H"
|
||||
"\n\r#repo-a: first\n\r# second [m-1]"
|
||||
"\n\rFrom:repo-a/o: hello"
|
||||
"\x1b[r\x1b8"
|
||||
)
|
||||
|
||||
|
||||
def test_terminal_frame_falls_back_when_stable_region_is_not_safe():
|
||||
expected = "\r\n#repo-a: hello [m-1]\r\n"
|
||||
assert terminal_frame("repo-a", "hello", "m-1", cursor_y=0, pane_height=24) == expected
|
||||
expected = "\r\nFrom:repo-a: hello\r\n"
|
||||
assert terminal_frame("repo-a", "hello", "worker_output", cursor_y=0, pane_height=24) == expected
|
||||
assert terminal_frame(
|
||||
"repo-a", "hello", "m-1", cursor_y=8, pane_height=24, alternate_on=True
|
||||
"repo-a", "hello", "worker_output", cursor_y=8, pane_height=24, alternate_on=True
|
||||
) == expected
|
||||
assert terminal_frame("repo-a", "hello", "m-1") == (
|
||||
"\r\n#repo-a: hello [m-1]\r\n"
|
||||
)
|
||||
|
||||
|
||||
def test_terminal_output_reaches_pty_output_but_not_input():
|
||||
master, slave = pty.openpty()
|
||||
try:
|
||||
tty_path = os.ttyname(slave)
|
||||
write_terminal_output(tty_path, terminal_frame("repo-a", "hello", "m-1"))
|
||||
write_terminal_output(tty_path, terminal_frame("repo-a", "hello", "worker_output"))
|
||||
|
||||
readable, _, _ = select.select([master], [], [], 1)
|
||||
assert readable == [master]
|
||||
assert b"#repo-a: hello [m-1]" in os.read(master, 4096)
|
||||
assert b"From:repo-a: hello" in os.read(master, 4096)
|
||||
readable_input, _, _ = select.select([slave], [], [], 0)
|
||||
assert readable_input == []
|
||||
finally:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue