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
|
|
@ -9,6 +9,7 @@ class FakeControl:
|
|||
def __init__(self, session):
|
||||
self.session = session
|
||||
self.injected = []
|
||||
self.placed = []
|
||||
self.submitted = []
|
||||
self.__class__.instances.append(self)
|
||||
|
||||
|
|
@ -24,6 +25,9 @@ class FakeControl:
|
|||
def submit(self, window, text):
|
||||
self.submitted.append((window, text))
|
||||
|
||||
def place(self, window, text):
|
||||
self.placed.append((window, text))
|
||||
|
||||
def pane_display(self, window):
|
||||
return PaneDisplay(
|
||||
tty_path=f"/dev/pts/{window.rsplit(':', 1)[-1]}",
|
||||
|
|
@ -43,7 +47,7 @@ def test_service_delivery_injects_pending_messages(tmp_path, monkeypatch):
|
|||
message_id = store.add("repo-a", "repo-b", "continue")
|
||||
monkeypatch.setattr("tamq.service.ControlModeClient", FakeControl)
|
||||
Service(store=store)._deliver_once()
|
||||
assert FakeControl.instances[-1].injected == [("tamq:repo-b", "#repo-a: continue")]
|
||||
assert FakeControl.instances[-1].injected == [("tamq:repo-b", "From:repo-a: continue")]
|
||||
assert store.list()[0]["message_id"] == message_id
|
||||
assert store.list()[0]["state"] == "injected"
|
||||
|
||||
|
|
@ -60,7 +64,7 @@ def test_service_never_injects_manual_endpoint_messages(tmp_path, monkeypatch):
|
|||
assert store.list()[0]["state"] == "pending"
|
||||
|
||||
|
||||
def test_service_pushy_mode_submits_once_and_marks_injected(tmp_path, monkeypatch):
|
||||
def test_service_pushy_mode_places_once_without_enter(tmp_path, monkeypatch):
|
||||
store = Store(tmp_path / "queue.sqlite3")
|
||||
store.register_endpoint("tmux-amq-9-boot", 9, "tamq", ["repo-b"], "pushy")
|
||||
message_id = store.add("repo-a", "repo-b", "first\nsecond")
|
||||
|
|
@ -71,22 +75,36 @@ def test_service_pushy_mode_submits_once_and_marks_injected(tmp_path, monkeypatc
|
|||
control = FakeControl.instances[-1]
|
||||
service._deliver_once()
|
||||
|
||||
assert control.submitted == [
|
||||
assert control.placed == [
|
||||
(
|
||||
"tamq:repo-b",
|
||||
f"# from repo-a: first\\x0asecond [{message_id}]",
|
||||
"From:repo-a: first\\x0asecond",
|
||||
)
|
||||
]
|
||||
assert control.submitted == []
|
||||
assert store.list()[0]["state"] == "injected"
|
||||
|
||||
|
||||
def test_service_trigger_mode_submits_exactly_once(tmp_path, monkeypatch):
|
||||
store = Store(tmp_path / "queue.sqlite3")
|
||||
store.register_endpoint("ep", 9, "tamq", ["repo-b"], "trigger")
|
||||
store.add("repo-a", "repo-b", "go", provenance="operator_input")
|
||||
monkeypatch.setattr("tamq.service.ControlModeClient", FakeControl)
|
||||
service = Service(store=store)
|
||||
service._deliver_once()
|
||||
control = FakeControl.instances[-1]
|
||||
service._deliver_once()
|
||||
assert control.submitted == [("tamq:repo-b", "From:repo-a/o: go")]
|
||||
assert control.placed == []
|
||||
|
||||
|
||||
def test_failed_pushy_submission_remains_pending(tmp_path, monkeypatch):
|
||||
store = Store(tmp_path / "queue.sqlite3")
|
||||
store.register_endpoint("tmux-amq-9-boot", 9, "tamq", ["repo-b"], "pushy")
|
||||
store.add("repo-a", "repo-b", "continue")
|
||||
|
||||
class FailingControl(FakeControl):
|
||||
def submit(self, window, text):
|
||||
def place(self, window, text):
|
||||
raise RuntimeError("tmux rejected input")
|
||||
|
||||
monkeypatch.setattr("tamq.service.ControlModeClient", FailingControl)
|
||||
|
|
@ -113,7 +131,7 @@ def test_service_writes_output_once_and_retains_pending_ack(tmp_path, monkeypatc
|
|||
assert writes == [
|
||||
(
|
||||
"/dev/pts/repo-b",
|
||||
f"\r\n#repo-a: continue [{message_id}]\r\n",
|
||||
"\r\nFrom:repo-a: continue\r\n",
|
||||
)
|
||||
]
|
||||
row = store.list()[0]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue