"""Teste pentru VIN pe rand separat sub numarul de inmatriculare. VIN-ul se afiseaza intr-un element block-level (div, stil muted) sub nr. inmatriculare, nu inline in aceeasi celula. Testul asserteaza tipul elementului (block), nu doar prezenta textului. """ from __future__ import annotations import json import os import re import tempfile import pytest from starlette.testclient import TestClient def _create_account_user(email: str, name: str = "Service", password: str = "parolasecreta10"): from app.accounts import create_account from app.users import create_user from app.db import get_connection conn = get_connection() try: acct_id = create_account(conn, name, active=True) create_user(conn, acct_id, email, password) return acct_id finally: conn.close() def _login(client, email: str, password: str = "parolasecreta10") -> None: resp = client.get("/login") m = re.search(r'name="csrf_token"\s+value="([^"]+)"', resp.text) or \ re.search(r'value="([^"]+)"\s+name="csrf_token"', resp.text) assert m resp = client.post( "/login", data={"email": email, "parola": password, "csrf_token": m.group(1)}, ) assert resp.status_code == 303 def _ins(acct: int, *, vin: str = "", nr: str = "B01TST", status: str = "queued") -> int: from app.db import get_connection conn = get_connection() try: cur = conn.execute( "INSERT INTO submissions (idempotency_key, account_id, status, payload_json) VALUES (?, ?, ?, ?)", ( f"k-{os.urandom(5).hex()}", acct, status, json.dumps({ "vin": vin, "nr_inmatriculare": nr, "data_prestatie": "2026-06-20", "odometru_final": "100", "prestatii": [{"cod_prestatie": "R-X"}], }), ), ) conn.commit() return cur.lastrowid # type: ignore[return-value] finally: conn.close() @pytest.fixture() def client(monkeypatch): tmp = tempfile.mkdtemp() monkeypatch.setenv("AUTOPASS_DB_PATH", os.path.join(tmp, "layout_test.db")) monkeypatch.setenv("AUTOPASS_WEB_AUTH_REQUIRED", "true") from app.config import get_settings get_settings.cache_clear() from app.web import ratelimit ratelimit._hits.clear() from app.main import app with TestClient(app, follow_redirects=False) as c: yield c ratelimit._hits.clear() get_settings.cache_clear() def test_placuta_pe_rand_identificator_primar(client): """Placuta (nr. inmatriculare) e identificatorul primar, linia 1 a randului slim, randata intr-un