Files
periscope/tests/datasheet/test_digikey_match.py
T
michele 4df04df5d4 Make the component library a standalone product door (2.63.0).
Add /api/library datasheet import and component GET/PUT with no exam.
Reorganize pytest into datasheet, library, schematic, PCB, and AF+AI.
Document Rust criteria (none chosen; no rustup) and coding conformity.
2026-09-21 22:12:00 +02:00

24 lines
918 B
Python

from backend.services.digikey import _find_product
def test_find_product_accepts_underscore_vs_slash():
products = [{"ManufacturerProductNumber": "25AA1024-I/SM", "DatasheetUrl": "http://a.pdf"}]
picked = _find_product("25AA1024-I_SM", products)
assert picked is not None
assert picked["DatasheetUrl"] == "http://a.pdf"
def test_find_product_accepts_family_orderable():
products = [
{"ManufacturerProductNumber": "24AA025E64-I/SN", "DatasheetUrl": "http://b.pdf"},
]
picked = _find_product("24AA025E64", products)
assert picked is not None
assert picked["DatasheetUrl"] == "http://b.pdf"
def test_find_product_rejects_unrelated():
products = [{"ManufacturerProductNumber": "GRM21BR61A106KE19L", "DatasheetUrl": "http://c.pdf"}]
assert _find_product("10uF", products) is None
assert _find_product("CH340", [{"ManufacturerProductNumber": "CH340E"}]) is None