Port Round 1 to Python (OrderDomain): 7 tests green, START state preserved

This commit is contained in:
2026-10-01 13:42:21 +01:00
parent 2831b8c3f9
commit 974053625d
5 changed files with 162 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
"""Custom matcher that bundles multiple order assertions into one.
Participants: you do not need to understand how this works —
just recognize the pattern and use it as an example for the agent.
"""
from decimal import Decimal
from order_domain import Order
def assert_order_state(
order: Order, *, total: Decimal, line_values: list[Decimal]
) -> None:
actual_total = order.total
actual_line_values = [line.value for line in order.lines]
details: list[str] = []
if actual_total != total:
details.append(f"Total: expected {total}, but was {actual_total}")
if actual_line_values != line_values:
details.append(
f"Line values: expected [{', '.join(str(v) for v in line_values)}], "
f"but was [{', '.join(str(v) for v in actual_line_values)}]"
)
if details:
header = (
f"Expected order with total {total} and line values "
f"[{', '.join(str(v) for v in line_values)}] but was:"
)
raise AssertionError("\n".join([header, *details]))