Download tests/test_grapp.py from grappapp/grapp: direct link, hf CLI and curl.
- Browser
- Download file 1.58 kB
-
https://huggingface.co/spaces/grappapp/grapp/resolve/main/tests/test_grapp.py
- Command line
-
hf download hf://spaces/grappapp/grapp/tests/test_grapp.py
-
curl -L -o test_grapp.py https://huggingface.co/spaces/grappapp/grapp/resolve/main/tests/test_grapp.py
1.58 kB
| """Tests rapides : python -m pytest -q (ou python tests/test_grapp.py)""" | |
| import sys | |
| from pathlib import Path | |
| sys.path.insert(0, str(Path(__file__).resolve().parents[1])) | |
| from grapp.carte import trouver_vins | |
| from grapp.engine import DicoVino, Grapp, Preferences | |
| G = Grapp(use_hf=False) | |
| NOMS = G.vins["nom"].tolist() | |
| def test_filtre_couleur_et_bulles(): | |
| r = G.recommander(Preferences(couleur="blanc", bulles="oui"), k=10) | |
| assert r and all(x.vin["couleur"] == "blanc" and x.vin["bulles"] == 1 for x in r) | |
| def test_huitres_donne_un_blanc_mineral(): | |
| p = Preferences(couleur="blanc", familles=["mineral"], occasion="repas", | |
| format="bouteille", budget=25, envie="huîtres et fruits de mer") | |
| assert G.recommander(p, k=1)[0].vin["famille"] == "mineral" | |
| def test_lecture_carte_tolere_fautes_ocr(): | |
| texte = "Cétes du Rhone, E. Guigal 2021 27€\nChampagne Brut, Maison X 68 €\nChablis ler Cru 48 €" | |
| res = {x["nom"]: x["prix_carte"] for x in trouver_vins(texte, NOMS)} | |
| assert res == {"Côtes du Rhône": 27.0, "Champagne Brut": 68.0, "Chablis": 48.0} | |
| def test_reco_limitee_a_la_carte_et_prix_resto(): | |
| r = G.recommander(Preferences(format="bouteille"), carte={"Chinon": 29.0, "Tavel": 30.0}) | |
| assert {x.nom for x in r} <= {"Chinon", "Tavel"} and {x.prix for x in r} <= {29.0, 30.0} | |
| def test_dico(): | |
| assert "Tanins" in DicoVino(use_hf=False).chercher("tanins")["terme"].tolist() | |
| if __name__ == "__main__": | |
| for n, f in list(globals().items()): | |
| if n.startswith("test_"): | |
| f(); print("OK", n) | |