Some checks failed
tamq-ci / test (push) Failing after 7s
Assistant: codex Assistant-Model: gpt-5.6-sol Assistant-Session: 01a03397-4d51-7fd1-8ff2-946eb22ea2bc
75 lines
2.2 KiB
Python
75 lines
2.2 KiB
Python
from tamq.cli import (
|
|
ensure_manual_service,
|
|
ensure_output_service,
|
|
ensure_pushy_service,
|
|
parse_size,
|
|
)
|
|
from tamq.service import PUSHY_FRAMING_CAPABILITY
|
|
|
|
|
|
def test_parse_size():
|
|
assert parse_size("100MB") == 100_000_000
|
|
assert parse_size("2KB") == 2_000
|
|
|
|
|
|
def test_manual_service_restarts_legacy_broker(monkeypatch):
|
|
capabilities = iter([[], ["manual_delivery"]])
|
|
starts = []
|
|
stops = []
|
|
|
|
async def request(payload):
|
|
assert payload == {"op": "ping"}
|
|
return {"ok": True, "capabilities": next(capabilities)}
|
|
|
|
monkeypatch.setattr("tamq.cli.ensure_service", lambda: starts.append(True) or True)
|
|
monkeypatch.setattr("tamq.cli.stop_service_process", lambda: stops.append(True) or 42)
|
|
monkeypatch.setattr("tamq.cli.request", request)
|
|
|
|
assert ensure_manual_service() is True
|
|
assert len(starts) == 2
|
|
assert stops == [True]
|
|
|
|
|
|
def test_output_service_requires_terminal_output_capability(monkeypatch):
|
|
capabilities = iter([
|
|
["manual_delivery"],
|
|
["manual_delivery", "terminal_output"],
|
|
])
|
|
starts = []
|
|
stops = []
|
|
|
|
async def request(payload):
|
|
return {"capabilities": next(capabilities)}
|
|
|
|
monkeypatch.setattr("tamq.cli.ensure_service", lambda: starts.append(True) or True)
|
|
monkeypatch.setattr("tamq.cli.stop_service_process", lambda: stops.append(True) or 42)
|
|
monkeypatch.setattr("tamq.cli.request", request)
|
|
|
|
assert ensure_output_service() is True
|
|
assert len(starts) == 2
|
|
assert stops == [True]
|
|
|
|
|
|
def test_pushy_service_requires_pushy_input_capability(monkeypatch):
|
|
capabilities = iter([
|
|
["manual_delivery", "terminal_output", "pushy_input"],
|
|
[
|
|
"manual_delivery",
|
|
"terminal_output",
|
|
"pushy_input",
|
|
PUSHY_FRAMING_CAPABILITY,
|
|
],
|
|
])
|
|
starts = []
|
|
stops = []
|
|
|
|
async def request(payload):
|
|
return {"capabilities": next(capabilities)}
|
|
|
|
monkeypatch.setattr("tamq.cli.ensure_service", lambda: starts.append(True) or True)
|
|
monkeypatch.setattr("tamq.cli.stop_service_process", lambda: stops.append(True) or 42)
|
|
monkeypatch.setattr("tamq.cli.request", request)
|
|
|
|
assert ensure_pushy_service() is True
|
|
assert len(starts) == 2
|
|
assert stops == [True]
|