ajout: modification test_main

This commit is contained in:
2026-02-09 22:14:52 +01:00
parent c62a5e6a76
commit 7cd40346c4
2 changed files with 8 additions and 19 deletions

View File

@@ -211,5 +211,3 @@ class Scraper:
raise ValueError(f"Clé manquante dans le JSON : {key}") raise ValueError(f"Clé manquante dans le JSON : {key}")
return _ScraperData(cast(dict[str, object], current_data)) return _ScraperData(cast(dict[str, object], current_data))
# print(Scraper().getjsondata("bordeaux.html?page=1").getdata())

View File

@@ -89,7 +89,7 @@ def mock_site():
"valueId": "93-94", "valueId": "93-94",
"name": "J. Suckling", "name": "J. Suckling",
"value": "93-94", "value": "93-94",
"isSpirit": False "isSpirit": False,
}, },
}, },
} }
@@ -121,31 +121,22 @@ def scraper() -> Scraper:
return Scraper() return Scraper()
# EXO1
def test_soup(scraper: Scraper): def test_soup(scraper: Scraper):
h1: Tag | None = scraper.getsoup("").find("h1") h1: Tag | None = scraper.getsoup("").find("h1")
assert isinstance(h1, Tag) assert isinstance(h1, Tag)
assert h1.text == "MILLESIMA" assert h1.text == "MILLESIMA"
# def test_getProductName(scraper: Scraper): # EXO3
# jsondata = scraper.getjsondata("nino-negri-5-stelle-sfursat-2022.html")
# assert jsondata["productName"] == "Nino Negri : 5 Stelle Sfursat 2022"
# assert isinstance(jsondata["items"], list)
# assert len(jsondata["items"]) > 0
# assert jsondata["items"][0]["offerPrice"] == 390
def test_appellation(scraper: Scraper): def test_appellation(scraper: Scraper):
appellation = scraper.getjsondata( appellation = scraper.getjsondata("nino-negri-5-stelle-sfursat-2022.html")
"nino-negri-5-stelle-sfursat-2022.html"
)
assert appellation.appellation() == "Sforzato di Valtellina" assert appellation.appellation() == "Sforzato di Valtellina"
# EXO4-5
def test_critiques(scraper: Scraper): def test_critiques(scraper: Scraper):
critiques = scraper.getjsondata( critiques = scraper.getjsondata("nino-negri-5-stelle-sfursat-2022.html")
"nino-negri-5-stelle-sfursat-2022.html"
)
assert critiques.parker() == "91" assert critiques.parker() == "91"
assert critiques.robinson() == "17" assert critiques.robinson() == "17"
assert critiques.suckling() == "93.5" assert critiques.suckling() == "93.5"