The evidence for track H, in the shape tracks A, E, B + G and F used.
- benchmarks/tasks_v7.py: 21 tasks, DEFAULT_MATRIX = "v7"; v6 to v2 stay
addressable. Both new tasks read the synthetic plant pair and nothing
else. takeoff_roundtrip: the P&ID called schematic, every routable run's
layout length equal to the rectilinear MST of its tags, sizes and services
as drawn (a return drawn on the supply layer included), the cable metres
rounded up after the allowance, an unstated power left empty.
understand_foreign: inches over millimetres flagged, the stray entity found
by handle, two plan copies separated, five layers classified. A test breaks
each input and watches its gate fail by name.
- Five correctness checks, every number worked out by hand in its docstring;
the published A/B report is re-run over 48 checks: 26 / 48 -> 48 / 48,
zero regressed.
- scripts/smoke_understand_com.py reads the pair through the live engine -
snapshots, the DWG route, both takeoffs and a diff - and closes every
document it opens; the CHANGELOG records what it returned.
scripts/field_test_takeoff.py runs the takeoffs on a user's own files,
refuses to write inside the repository and prints no quantity by default.
- The README token table is remeasured; check_doc_numbers derives the task
count from the v7 matrix; CLAUDE.md, both READMEs, the CHANGELOG and the
spec status line say what shipped.
One reader defect found on the way: describe.tag_occurrences read a wiring
callout ("Wiring to CP-2") as a place its panel is written, so the scale
check called CP-2 ambiguous and read "Wiring to CP1" as a phantom tag CP1 -
10 tags and 45 pairs (13.3 % within 10 %) where the generator placed 11 and
55 (21.8 %). A callout is no longer a tag occurrence, the rule
network.tag_occurrences already kept; two tests failed before the fix.
The smoke works only in documents it opened from its own temporary folder,
known by full path; it attaches with GetActiveObject only (the backend's
Dispatch fallback would launch AutoCAD), checks in the same COM-thread call
that the active document is its own before each snapshot, the DWG save and
the move, closes its documents with Close(False) and re-activates the
document that was active when it started. No new ActiveX member: Documents,
Item, FullName, ActiveDocument, Activate and Close are the ones the backend
already calls. Measured on AutoCAD 2026 (25.1s): exit 0, model-space types
equal file / live / DWG, export 0.104 s, no document of the run left open.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FKFStjEFzpGyLq5bMpWxTd
70 lines
2.6 KiB
Python
70 lines
2.6 KiB
Python
"""scripts/field_test_takeoff.py never writes into the repository and never prints a quantity.
|
|
|
|
The script exists for client drawings, which never enter this repository
|
|
(spec §14). It is exercised here on the synthetic plant pair only - the field
|
|
test itself is never run in CI.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import importlib.util
|
|
import json
|
|
from pathlib import Path
|
|
|
|
from tests.fixtures.plant_pair import build_plant_pair
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
|
|
|
|
def _script():
|
|
spec = importlib.util.spec_from_file_location(
|
|
"field_test_takeoff", ROOT / "scripts" / "field_test_takeoff.py"
|
|
)
|
|
module = importlib.util.module_from_spec(spec)
|
|
spec.loader.exec_module(module)
|
|
return module
|
|
|
|
|
|
def test_an_output_folder_inside_the_repository_is_refused_before_anything_runs(tmp_path, capsys):
|
|
truth = build_plant_pair(tmp_path)
|
|
target = ROOT / "field_test_output_must_not_exist"
|
|
code = _script().main(
|
|
["--pid", truth["pid"], "--layout", truth["layout"], "--out", str(target)]
|
|
)
|
|
assert code == 2
|
|
assert not target.exists()
|
|
assert "refused" in capsys.readouterr().out
|
|
|
|
|
|
def test_a_missing_drawing_is_refused(tmp_path, capsys):
|
|
code = _script().main(
|
|
["--pid", str(tmp_path / "none.dxf"), "--layout", str(tmp_path / "none.dxf")]
|
|
)
|
|
assert code == 2
|
|
assert "does not exist" in capsys.readouterr().out
|
|
|
|
|
|
def test_the_report_lands_next_to_the_pid_and_the_console_carries_no_quantity(tmp_path, capsys):
|
|
truth = build_plant_pair(tmp_path)
|
|
code = _script().main(["--pid", truth["pid"], "--layout", truth["layout"]])
|
|
assert code == 0
|
|
summary = json.loads(capsys.readouterr().out)
|
|
assert summary["scale_verdict"] == "schematic"
|
|
assert Path(summary["report"]).parent == tmp_path
|
|
assert all(Path(path).parent == tmp_path for path in summary["workbooks"])
|
|
printed = json.dumps({k: v for k, v in summary.items() if k not in ("report", "workbooks")})
|
|
for run in truth["pipe_runs"]:
|
|
if run["layout_length_mm"] is not None:
|
|
assert f"{run['layout_length_mm']:g}" not in printed, run["id"]
|
|
for row in truth["cable_rows"]:
|
|
assert f"{row['length_mm']:g}" not in printed, row["tag"]
|
|
report = json.loads(Path(summary["report"]).read_text(encoding="utf-8"))
|
|
assert report["scale"]["verdict"] == "schematic"
|
|
|
|
|
|
def test_show_prints_the_rows_on_request(tmp_path, capsys):
|
|
truth = build_plant_pair(tmp_path)
|
|
code = _script().main(["--pid", truth["pid"], "--layout", truth["layout"], "--show"])
|
|
assert code == 0
|
|
assert '"cable"' in capsys.readouterr().out
|