1er
This commit is contained in:
0
backend/app/tests/__init__.py
Normal file
0
backend/app/tests/__init__.py
Normal file
BIN
backend/app/tests/__pycache__/__init__.cpython-313.pyc
Normal file
BIN
backend/app/tests/__pycache__/__init__.cpython-313.pyc
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
16
backend/app/tests/test_normalize.py
Normal file
16
backend/app/tests/test_normalize.py
Normal file
@@ -0,0 +1,16 @@
|
||||
from backend.app.scraper.normalize import parse_price_fr, parse_rating_count, parse_rating_value
|
||||
|
||||
|
||||
def test_parse_price_fr():
|
||||
assert parse_price_fr("1 249,99 €") == 1249.99
|
||||
assert parse_price_fr("249,99") == 249.99
|
||||
|
||||
|
||||
def test_parse_rating_value():
|
||||
assert parse_rating_value("4,7 sur 5") == 4.7
|
||||
assert parse_rating_value("4.0") == 4.0
|
||||
|
||||
|
||||
def test_parse_rating_count():
|
||||
assert parse_rating_count("1 234 évaluations") == 1234
|
||||
assert parse_rating_count("987") == 987
|
||||
22
backend/app/tests/test_parser_samples.py
Normal file
22
backend/app/tests/test_parser_samples.py
Normal file
@@ -0,0 +1,22 @@
|
||||
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
|
||||
13
backend/app/tests/test_pricing.py
Normal file
13
backend/app/tests/test_pricing.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from backend.app.services.pricing import price_trend
|
||||
|
||||
|
||||
def test_price_trend_up():
|
||||
assert price_trend([100, 200]) == "up"
|
||||
|
||||
|
||||
def test_price_trend_stable():
|
||||
assert price_trend([100, 100]) == "stable"
|
||||
|
||||
|
||||
def test_price_trend_down():
|
||||
assert price_trend([300, 200]) == "down"
|
||||
Reference in New Issue
Block a user