Persist recovered ferrite Z by comparing against the raw JSON.

ComponentModel validation already fills impedance from quoted ohm@freq, so snapshotting the in-memory specs skipped the write.
This commit is contained in:
2026-09-21 00:33:17 +02:00
parent 72bcab50a1
commit e31981c812
2 changed files with 27 additions and 2 deletions
+24
View File
@@ -220,6 +220,30 @@ def test_bead_mpn_datasheet_pdf_fills_z(tmp_path: Path):
assert "100" in (persisted["specs"].get("value_formatted") or "")
def test_bead_live_json_persist_unstuffs_henries(tmp_path: Path):
models = tmp_path / "models"
models.mkdir()
payload = {
"mpn": "BLM21PG121SN1D",
"specs": {
"specs_type": "inductor",
"component_subtype": "passive.ferrite_bead",
"value_henries": 120.0,
"value_formatted": "120 ohm @ 100 MHz",
"package": "0805",
"current_rating_a": "3A",
"dcr_ohms": 0.03,
},
}
(models / "BLM21PG121SN1D.json").write_text(json.dumps(payload) + "\n")
loaded = _load_component_models(models)
assert loaded["BLM21PG121SN1D"].impedance_ohm == 120.0
assert loaded["BLM21PG121SN1D"].value_henries is None
persisted = json.loads((models / "BLM21PG121SN1D.json").read_text())
assert persisted["specs"]["impedance_ohm"] == 120.0
assert persisted["specs"]["value_henries"] is None
def test_bead_mpn_datasheet_pdf_without_z_does_not_invent(tmp_path: Path):
models = tmp_path / "models"
models.mkdir()