"""Gardii pentru corectia anvelope->OE-8 (tools/mapare-llm/fix_anvelope_oe8.py). Doua niveluri: 1. Regula `este_inlocuire_anvelope` pe cazuri pozitive/negative. 2. Seed-ul real din repo NU mai contine inlocuiri de anvelope etichetate altfel decat OE-8 (regresie la o viitoare regenerare a seed-ului). """ from __future__ import annotations import json import os import sys HERE = os.path.dirname(os.path.abspath(__file__)) TOOLS_DIR = os.path.abspath(os.path.join(HERE, "..", "tools", "mapare-llm")) if TOOLS_DIR not in sys.path: sys.path.insert(0, TOOLS_DIR) from fix_anvelope_oe8 import SEED_PATH, este_inlocuire_anvelope # noqa: E402 def test_regula_pozitive(): for t in [ "INLOCUIT ANVELOPE B 55 XMH", "INLOCUIT ANVELOPE 2 BUC", "INLOCUIT + ECHILIBRAT ANVELOPE", "SCHIMBAT ANVELOPE VARA", "MONTAT ANVELOPE (2)", "INL ANVELOPE + ECHILIBR", ]: assert este_inlocuire_anvelope(t), t def test_regula_negative(): for t in [ "INLOCUIT ANVELOPA DR FATA", # singular cu pozitie = context reparatie "D/R ANVELOPE(4 BUC)", # demontat/remontat, nu inlocuire "INLOCUIT ANVELOPA+JANTA", # janta = reparatie "REPARAT ANVELOPE", # vulcanizare/reparatie "CHIRIE ANVELOPE AUGUST", # non-operatie (fara verb de inlocuire) "INLOCUIT PLACUTE FRANA", # alta piesa "VERIFICAT PRESIUNE ANVELOPE", # verificare, nu inlocuire ]: assert not este_inlocuire_anvelope(t), t def test_seed_fara_inlocuiri_anvelope_gresite(): """Orice intrare de inlocuire anvelope din seed trebuie sa fie OE-8.""" with open(SEED_PATH, encoding="utf-8") as f: items = json.load(f) gresite = [ it["denumire_normalizata"] for it in items if not it.get("is_nul") and este_inlocuire_anvelope(it.get("denumire_normalizata") or "") and it.get("cod") != "OE-8" ] assert gresite == [], f"{len(gresite)} inlocuiri de anvelope ne-OE-8 in seed: {gresite[:5]}"