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.
53 lines
1.6 KiB
Python
53 lines
1.6 KiB
Python
"""Tests for mckicad.config — lazy configuration functions."""
|
|
|
|
def test_kicad_extensions_has_required_types():
|
|
from mckicad.config import KICAD_EXTENSIONS
|
|
|
|
assert "project" in KICAD_EXTENSIONS
|
|
assert "pcb" in KICAD_EXTENSIONS
|
|
assert "schematic" in KICAD_EXTENSIONS
|
|
assert KICAD_EXTENSIONS["project"] == ".kicad_pro"
|
|
|
|
|
|
def test_timeout_constants_are_positive():
|
|
from mckicad.config import TIMEOUT_CONSTANTS
|
|
|
|
for key, val in TIMEOUT_CONSTANTS.items():
|
|
assert val > 0, f"Timeout {key} must be positive"
|
|
|
|
|
|
def test_get_search_paths_reads_env(monkeypatch, tmp_path):
|
|
test_dir = str(tmp_path)
|
|
monkeypatch.setenv("KICAD_SEARCH_PATHS", test_dir)
|
|
|
|
from mckicad.config import get_search_paths
|
|
|
|
paths = get_search_paths()
|
|
assert test_dir in paths
|
|
|
|
|
|
def test_get_search_paths_filters_nonexistent(monkeypatch):
|
|
monkeypatch.setenv("KICAD_SEARCH_PATHS", "/nonexistent/path/abc123")
|
|
|
|
from mckicad.config import get_search_paths
|
|
|
|
paths = get_search_paths()
|
|
assert "/nonexistent/path/abc123" not in paths
|
|
|
|
|
|
def test_get_kicad_user_dir_env_override(monkeypatch):
|
|
monkeypatch.setenv("KICAD_USER_DIR", "/custom/kicad/dir")
|
|
|
|
from mckicad.config import get_kicad_user_dir
|
|
|
|
assert get_kicad_user_dir() == "/custom/kicad/dir"
|
|
|
|
|
|
def test_common_libraries_structure():
|
|
from mckicad.config import COMMON_LIBRARIES
|
|
|
|
assert "basic" in COMMON_LIBRARIES
|
|
assert "resistor" in COMMON_LIBRARIES["basic"]
|
|
assert "library" in COMMON_LIBRARIES["basic"]["resistor"]
|
|
assert "symbol" in COMMON_LIBRARIES["basic"]["resistor"]
|