tmux-amq/tests/test_routing.py
tegwick cd73b954e9
Some checks failed
tamq-ci / test (push) Failing after 5s
fix: route case-insensitive worker messages
Assistant: codex
Assistant-Model: gpt-5.6-sol
Assistant-Session: 01a03397-4d51-7fd1-8ff2-946eb22ea2bc
2026-08-25 22:13:32 +02:00

53 lines
1.7 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import pytest
from tamq.routing import (
is_delivery_line,
parse_address_line,
parse_command_line,
parse_worker_address_line,
)
@pytest.mark.parametrize("keyword", ["to", "To", "TO", "tO"])
def test_direct_address_keyword_is_case_insensitive(keyword):
routed = parse_address_line(
f"{keyword}:railiance-platform: do something!"
)
assert routed.body == "do something!"
assert routed.target_repo == "railiance-platform"
@pytest.mark.parametrize(
"line",
[
"@repo: removed",
"#repo: removed",
"hello To:repo: not at start",
"To:repo:",
"From:repo: inbound envelope",
],
)
def test_non_protocol_and_legacy_input_is_not_routed(line):
assert parse_address_line(line) is None
@pytest.mark.parametrize("keyword", ["cmd", "Cmd", "CMD", "cMd"])
def test_operator_command_keyword_is_case_insensitive(keyword):
assert parse_command_line(f"{keyword}: mode=trigger") == "mode=trigger"
assert parse_command_line(f"{keyword}: reset-limits") == "reset-limits"
@pytest.mark.parametrize("keyword", ["from", "From", "FROM", "fRoM"])
def test_delivery_keyword_is_case_insensitive(keyword):
assert is_delivery_line(f"{keyword}:repo: inbound envelope") is True
@pytest.mark.parametrize("gutter", ["", "", "", ""])
def test_worker_address_accepts_terminal_output_gutter(gutter):
routed = parse_worker_address_line(f"{gutter}tO:target: worker reply")
assert routed == parse_address_line("To:target: worker reply")
@pytest.mark.parametrize("gutter", [" ", "> ", "$ ", "# ", "* ", "- "])
def test_worker_address_rejects_operator_and_markup_gutters(gutter):
assert parse_worker_address_line(f"{gutter}To:target: operator echo") is None