ajout fonction prix

This commit is contained in:
Chahrazad650
2026-02-07 02:21:30 +01:00
parent 5797b72cbc
commit 6366fcd8dd
2 changed files with 125 additions and 83 deletions

View File

@@ -1,6 +1,35 @@
from main import *
import json
from main import Scraper
scraper = Scraper()
def test_soup():
assert scraper.getsoup().find('h1').text[3:12] == "MILLESIMA"
def test_json():
scraper = Scraper()
data = scraper.getjsondata("/chateau-gloria-2016.html")
print("JSON récupéré :")
print(json.dumps(data, indent=4, ensure_ascii=False))
assert isinstance(data, dict)
assert "items" in data
def test_prix():
scraper = Scraper()
try:
p = scraper.prix("/chateau-saint-pierre-2011.html")
print("Prix unitaire =", p)
assert isinstance(p, float)
assert p > 0
except ValueError:
# le vin n'est pas disponible à la vente
print("OK : aucun prix (vin indisponible, items vide)")
if __name__ == "__main__":
test_json()
test_prix()
print("\nTous les tests terminés")