Spaces:
Running on Zero
Running on Zero
Download backend/tests/test_export.py from mindchainai/PCB_agentic_ai: direct link, hf CLI and curl.
- Browser
- Download file 1.46 kB
-
https://huggingface.co/spaces/mindchainai/PCB_agentic_ai/resolve/main/backend/tests/test_export.py
- Command line
-
hf download hf://spaces/mindchainai/PCB_agentic_ai/backend/tests/test_export.py
-
curl -L -o test_export.py https://huggingface.co/spaces/mindchainai/PCB_agentic_ai/resolve/main/backend/tests/test_export.py
1.46 kB
| """KiCad export must parse as a real KiCad board; BOM/layout must match the design.""" | |
| import csv | |
| import io | |
| from kiutils.board import Board | |
| from app.export import bom_csv, layout_json, to_kicad_pcb | |
| def test_kicad_pcb_parses_and_matches(example_design, tmp_path): | |
| d = example_design | |
| path = tmp_path / "board.kicad_pcb" | |
| text = to_kicad_pcb(d, 'Test "quoted" board') | |
| path.write_text(text, encoding="utf-8") | |
| assert text.count("(") == text.count(")") | |
| b = Board.from_file(str(path)) | |
| assert len(b.footprints) == len(d.components) | |
| assert len(b.nets) == len(d.nets) + 1 | |
| segs = sum(len(p.points) - 1 for r in d.routes for p in r.paths) | |
| vias = sum(len(r.vias) for r in d.routes) | |
| assert len(b.traceItems) == segs + vias | |
| assert sum(len(f.pads) for f in b.footprints) == sum(len(c.pads) for c in d.components) | |
| names = {n.name for n in b.nets} | |
| assert {"GND", "+3V3", "VBUS"} <= names | |
| edge = [g for g in b.graphicItems if getattr(g, "layer", "") == "Edge.Cuts"] | |
| assert edge, "board outline present" | |
| def test_bom_and_layout(example_design): | |
| d = example_design | |
| rows = list(csv.DictReader(io.StringIO(bom_csv(d)))) | |
| assert sum(int(r["Quantity"]) for r in rows) == len(d.components) | |
| lay = layout_json(d) | |
| assert len(lay["components"]) == len(d.components) | |
| assert len(lay["tracks"]) == sum(len(r.paths) for r in d.routes) | |
| assert lay["units"] == "mm" | |