Pipeline and LCSC resolve call datasheet_extract; inherited extraction.py stays in dependency as fallback. No Anthropic Console skill ids.
32 lines
1.1 KiB
Python
32 lines
1.1 KiB
Python
"""Native datasheet_extract vs inherited extraction — prove before switching pipeline."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import ast
|
|
from pathlib import Path
|
|
|
|
from backend.services.datasheet_extract import _coerce_abs_max
|
|
from backend.services.extraction import _coerce_abs_max as inherited_coerce
|
|
|
|
|
|
def test_coerce_abs_max_matches_inherited():
|
|
raw = [
|
|
{"parameter": "Vin", "min": 0, "max": 6, "unit": "V", "source_page": 4},
|
|
"not-a-dict",
|
|
]
|
|
assert _coerce_abs_max(raw) == inherited_coerce(raw)
|
|
assert _coerce_abs_max(None) == inherited_coerce(None)
|
|
|
|
|
|
def test_native_extract_has_no_anthropic_import():
|
|
path = Path(__import__("backend.services.datasheet_extract", fromlist=["x"]).__file__)
|
|
tree = ast.parse(path.read_text())
|
|
imported = []
|
|
for node in ast.walk(tree):
|
|
if isinstance(node, ast.ImportFrom) and node.module:
|
|
imported.append(node.module)
|
|
elif isinstance(node, ast.Import):
|
|
imported.extend(a.name for a in node.names)
|
|
assert not any("anthropic" in (m or "") for m in imported)
|
|
assert "backend.services.llm.factory" in imported
|