37 lines
1.3 KiB
Python
37 lines
1.3 KiB
Python
def test_create_recolte(client):
|
|
# créer jardin + plante + plantation d'abord
|
|
g = client.post(
|
|
"/api/gardens",
|
|
json={"nom": "J", "grille_largeur": 2, "grille_hauteur": 2, "type": "plein_air"},
|
|
).json()
|
|
p = client.post("/api/plants", json={"nom_commun": "Tomate"}).json()
|
|
pl = client.post(
|
|
"/api/plantings",
|
|
json={"garden_id": g["id"], "variety_id": p["id"], "quantite": 1, "statut": "en_cours"},
|
|
).json()
|
|
r = client.post(
|
|
f"/api/plantings/{pl['id']}/recoltes",
|
|
json={"quantite": 2.5, "unite": "kg", "date_recolte": "2026-08-01"},
|
|
)
|
|
assert r.status_code == 201
|
|
assert r.json()["quantite"] == 2.5
|
|
|
|
|
|
def test_list_recoltes(client):
|
|
g = client.post(
|
|
"/api/gardens",
|
|
json={"nom": "J", "grille_largeur": 2, "grille_hauteur": 2, "type": "plein_air"},
|
|
).json()
|
|
p = client.post("/api/plants", json={"nom_commun": "Tomate"}).json()
|
|
pl = client.post(
|
|
"/api/plantings",
|
|
json={"garden_id": g["id"], "variety_id": p["id"], "quantite": 1, "statut": "en_cours"},
|
|
).json()
|
|
client.post(
|
|
f"/api/plantings/{pl['id']}/recoltes",
|
|
json={"quantite": 1, "unite": "kg", "date_recolte": "2026-08-01"},
|
|
)
|
|
r = client.get(f"/api/plantings/{pl['id']}/recoltes")
|
|
assert r.status_code == 200
|
|
assert len(r.json()) == 1
|