mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-15 13:04:36 +00:00
test: surface path timing contracts in live harness
This commit is contained in:
parent
4b193e639c
commit
be6be4da36
9 changed files with 305 additions and 38 deletions
|
|
@ -1,6 +1,8 @@
|
|||
from pathlib import Path
|
||||
|
||||
from tools.pathing_contract_report import parse_metrics
|
||||
import pytest
|
||||
|
||||
from tools.pathing_contract_report import MetricsReport, SegmentMetric, parse_metrics, validate_report
|
||||
|
||||
|
||||
def test_parse_metrics_reads_route_and_segment_ticks(tmp_path: Path) -> None:
|
||||
|
|
@ -12,3 +14,27 @@ def test_parse_metrics_reads_route_and_segment_ticks(tmp_path: Path) -> None:
|
|||
|
||||
assert report.total_ticks == 70
|
||||
assert [segment.ticks for segment in report.segments] == [17, 16]
|
||||
|
||||
|
||||
def test_validate_report_includes_route_and_segment_table_on_budget_failure() -> None:
|
||||
report = MetricsReport(
|
||||
segments=[SegmentMetric(index=0, move="Parkour", ticks=17)],
|
||||
total_ticks=70,
|
||||
replans=0,
|
||||
planned=[],
|
||||
)
|
||||
planner_contract = {"segments": []}
|
||||
timing_budget = {
|
||||
"expectedTotalTicks": 60,
|
||||
"maxTotalTicks": 65,
|
||||
"segments": [
|
||||
{"moveType": "Parkour", "expectedTicks": 15, "maxTicks": 16},
|
||||
],
|
||||
}
|
||||
|
||||
with pytest.raises(SystemExit) as exc:
|
||||
validate_report("sample-scenario", report, planner_contract, timing_budget)
|
||||
|
||||
message = str(exc.value)
|
||||
assert "Route sample-scenario: actual=70 expected=60 max=65" in message
|
||||
assert "seg[0] move=Parkour actual=17 expected=15 max=16 delta=+2" in message
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue