HERMES-GIELIE/tests/test_background_process_wakeup_format.py
2026-06-18 16:17:27 +02:00

54 lines
1.6 KiB
Python

from api.background_process import format_wakeup_prompt
def test_format_wakeup_prompt_skips_empty_event():
assert format_wakeup_prompt({}) is None
def test_format_wakeup_prompt_skips_unknown_event_type():
evt = {"type": "unknown_event", "message": "do not inject me"}
assert format_wakeup_prompt(evt) is None
def test_format_wakeup_prompt_handles_watch_overflow_tripped():
evt = {
"type": "watch_overflow_tripped",
"session_id": "",
"session_key": "",
"command": "",
"message": "Watch-pattern overflow: suppressing further watch_match events.",
}
assert (
format_wakeup_prompt(evt)
== "[IMPORTANT: Watch-pattern overflow: suppressing further watch_match events.]"
)
def test_format_wakeup_prompt_handles_watch_overflow_released():
evt = {
"type": "watch_overflow_released",
"session_id": "",
"session_key": "",
"command": "",
"suppressed": 3,
"message": "Watch-pattern notifications resumed. 3 match event(s) were suppressed.",
}
assert (
format_wakeup_prompt(evt)
== "[IMPORTANT: Watch-pattern notifications resumed. 3 match event(s) were suppressed.]"
)
def test_format_wakeup_prompt_keeps_normal_completion():
evt = {
"type": "completion",
"session_id": "proc_abc",
"command": "sleep 1",
"exit_code": 0,
"output": "done",
}
result = format_wakeup_prompt(evt)
assert result is not None
assert "Background process proc_abc completed" in result
assert "Command: sleep 1" in result
assert "Output:\ndone" in result