Files
periscope/tests/test_si_check.py
micheleandCursor 8d2b85600f Rebrand Pinscope to Periscope across product and codebase.
Rename the core package to periscopex, update UI/docs/Docker/deploy defaults to periscope.michelebigi.it, and keep legacy version/storage key aliases so existing projects keep working.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-13 20:02:04 +02:00

48 lines
1.4 KiB
Python

"""G1 SI vs simple_project — no invented millimetres or USBPHY boards.
Favor: real /USB.D+ and /USB.D- pair by suffix; eval stays 3 keys.
Against: no .kicad_pcb → no PE-SI-001; 3W is not invented.
"""
from __future__ import annotations
from pathlib import Path
from backend.periscopex.eval_report import eval_simple_project
from backend.periscopex.models import DesignGraph
from backend.periscopex.si_check import check_si, partner_net
SIMPLE = Path(__file__).resolve().parents[1] / "simple_project"
def _graph() -> DesignGraph:
return DesignGraph.model_validate_json(
(SIMPLE / "design_graph.json").read_text()
)
def test_simple_project_usb_dp_dm_are_a_named_pair():
g = _graph()
assert "/USB.D+" in g.nets
assert "/USB.D-" in g.nets
assert partner_net("/USB.D+") == "/USB.D-"
assert partner_net("/USB.D-") == "/USB.D+"
assert partner_net("/USBC.D+") == "/USBC.D-"
def test_simple_project_without_pcb_has_no_ps_si_001():
findings = check_si(_graph(), {}, None)
assert findings == []
assert all(f.rule_id != "PE-3W-001" for f in findings)
def test_simple_project_eval_has_no_si_keys():
scores = eval_simple_project(SIMPLE)
assert scores.finding_count == 3
assert scores.precision == 1.0
assert scores.recall == 1.0
assert not any(
k.startswith("PE-SI-") or k.startswith("PE-3W-")
for k in scores.extra_keys
)