kicad-mcp/tests/test_bom.py
Ryan Malloy 4ae38fed59 Rebuild on FastMCP 3 with src-layout and kicad-sch-api integration
Migrate from FastMCP 2.14.5 to 3.1.0 with complete architectural
overhaul. Adopt src-layout packaging, lazy config functions to
eliminate .env race condition, and decorator-based tool registration.

Consolidate 14 tool modules into 8 focused modules (33 tools total).
Add 9 new schematic tools via kicad-sch-api for creating and
manipulating .kicad_sch files. Drop pandas dependency (BOM uses
stdlib csv). Remove ~17k lines of stubs, over-engineering, and
dead code.

All checks pass: ruff clean, mypy 0 errors, 17/17 tests green.
2026-03-03 18:26:54 -07:00

34 lines
1004 B
Python

"""Tests for BOM tools."""
import csv
import pytest
@pytest.mark.unit
def test_analyze_bom_no_csv(project_path):
"""analyze_bom with no CSV files should return empty results gracefully."""
from mckicad.tools.bom import analyze_bom
result = analyze_bom(project_path)
# Should succeed but find no data
assert isinstance(result, dict)
@pytest.mark.unit
def test_analyze_bom_with_csv(tmp_project_dir, project_path):
"""analyze_bom should parse a BOM CSV file."""
from mckicad.tools.bom import analyze_bom
# Create a simple BOM CSV
bom_path = tmp_project_dir / "test_project-bom.csv"
with open(bom_path, "w", newline="") as f:
writer = csv.writer(f)
writer.writerow(["Reference", "Value", "Footprint", "Qty"])
writer.writerow(["R1", "10k", "0805", "1"])
writer.writerow(["R2", "4.7k", "0805", "1"])
writer.writerow(["C1", "100nF", "0805", "1"])
result = analyze_bom(project_path)
assert isinstance(result, dict)