"""Periscope models load from src; layout primitives stay disjoint.""" from __future__ import annotations from pathlib import Path import backend.periscopex.models as models from backend.periscopex.models import ( LayoutPad, LayoutSegment, LayoutVia, LayoutZone, ) def test_models_module_is_src(): path = Path(models.__file__).resolve() assert path.parts[-5:] == ("periscope", "src", "backend", "periscopex", "models.py") text = path.read_text(encoding="utf-8") assert "Native Periscope overlay" not in text assert "pad (component pin land)" in text def test_pad_via_track_zone_are_distinct_types(): pad = LayoutPad(number="1", x=0.0, y=0.0, net="GND") via = LayoutVia(x=0.0, y=0.0, net="GND", drill=0.3) track = LayoutSegment(start=(0.0, 0.0), end=(1.0, 0.0), net="GND") zone = LayoutZone(net="GND", layer="F.Cu") kinds = {type(pad), type(via), type(track), type(zone)} assert len(kinds) == 4 assert not hasattr(via, "number") assert hasattr(pad, "number") assert not hasattr(track, "drill") assert not hasattr(zone, "drill") assert pad.model_dump() != via.model_dump() def test_via_is_not_a_pad_even_on_same_net_and_xy(): """Negative: same net and coordinates do not make a via a pad.""" pad = LayoutPad(number="2", x=1.0, y=2.0, net="3V3") via = LayoutVia(x=1.0, y=2.0, net="3V3", drill=0.2) assert type(via) is not type(pad) assert "number" not in type(via).model_fields assert "number" in type(pad).model_fields