from pathlib import Path

from backend.app.scraper.amazon.parser import extract_product_data_from_html


def test_extract_product_data_from_sample_html():
    html_path = Path(__file__).resolve().parent.parent / "samples" / "amazon_product.html"
    html = html_path.read_text(encoding="utf-8")
    data = extract_product_data_from_html(html, "https://www.amazon.fr/dp/B000000000")

    assert data["asin"] == "B000000000"
    assert data["titre"] == "Disque SSD NVMe Test"
    assert data["prix_actuel"] == 249.99
    assert data["prix_conseille"] == 329.99
    assert data["note"] == 4.7
    assert data["nombre_avis"] == 1234
    assert data["en_stock"] is True
    assert data["choix_amazon"] is True
    assert data["offre_limitee"] is True
    assert data["prime"] is True
    assert data["exclusivite_amazon"] is True
    assert data["prix_min_30j"] == 239.99
