fix: route case-insensitive worker messages
Some checks failed
tamq-ci / test (push) Failing after 5s
Some checks failed
tamq-ci / test (push) Failing after 5s
Assistant: codex Assistant-Model: gpt-5.6-sol Assistant-Session: 01a03397-4d51-7fd1-8ff2-946eb22ea2bc
This commit is contained in:
parent
fbb56f5981
commit
cd73b954e9
14 changed files with 183 additions and 37 deletions
|
|
@ -1,10 +1,18 @@
|
|||
import pytest
|
||||
|
||||
from tamq.routing import parse_address_line, parse_command_line
|
||||
from tamq.routing import (
|
||||
is_delivery_line,
|
||||
parse_address_line,
|
||||
parse_command_line,
|
||||
parse_worker_address_line,
|
||||
)
|
||||
|
||||
|
||||
def test_direct_address_uses_readable_case_sensitive_grammar():
|
||||
routed = parse_address_line("To:railiance-platform: do something!")
|
||||
@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"
|
||||
|
||||
|
|
@ -14,7 +22,6 @@ def test_direct_address_uses_readable_case_sensitive_grammar():
|
|||
[
|
||||
"@repo: removed",
|
||||
"#repo: removed",
|
||||
"to:repo: wrong case",
|
||||
"hello To:repo: not at start",
|
||||
"To:repo:",
|
||||
"From:repo: inbound envelope",
|
||||
|
|
@ -24,7 +31,23 @@ def test_non_protocol_and_legacy_input_is_not_routed(line):
|
|||
assert parse_address_line(line) is None
|
||||
|
||||
|
||||
def test_operator_command_grammar():
|
||||
assert parse_command_line("Cmd: mode=trigger") == "mode=trigger"
|
||||
assert parse_command_line("Cmd: reset-limits") == "reset-limits"
|
||||
assert parse_command_line("cmd: mode=trigger") 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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue