mirror of
https://github.com/guezoloic/millesima-ai-engine.git
synced 2026-03-31 11:11:37 +00:00
ajout fonction prix
This commit is contained in:
37
test_main.py
37
test_main.py
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user