fix(plantes): test plant_variety + seed PlantVariety + formatPlantLabel + migrate.py nettoyage
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -12,14 +12,30 @@ def test_list_plants(client):
|
||||
assert len(r.json()) == 2
|
||||
|
||||
|
||||
def test_allow_same_common_name_with_different_varieties(client):
|
||||
client.post("/api/plants", json={"nom_commun": "Tomate", "variete": "Roma"})
|
||||
client.post("/api/plants", json={"nom_commun": "Tomate", "variete": "Andine Cornue"})
|
||||
r = client.get("/api/plants")
|
||||
assert r.status_code == 200
|
||||
tomates = [p for p in r.json() if p["nom_commun"] == "Tomate"]
|
||||
assert len(tomates) == 2
|
||||
assert {p.get("variete") for p in tomates} == {"Roma", "Andine Cornue"}
|
||||
def test_plant_variety_crud(client):
|
||||
# Créer une plante
|
||||
r = client.post("/api/plants", json={"nom_commun": "Tomate"})
|
||||
assert r.status_code == 201
|
||||
plant_id = r.json()["id"]
|
||||
|
||||
# Créer deux variétés
|
||||
r1 = client.post(f"/api/plants/{plant_id}/varieties", json={"variete": "Roma"})
|
||||
assert r1.status_code == 201
|
||||
vid1 = r1.json()["id"]
|
||||
|
||||
r2 = client.post(f"/api/plants/{plant_id}/varieties", json={"variete": "Andine Cornue"})
|
||||
assert r2.status_code == 201
|
||||
|
||||
# GET /plants/{id} doit retourner les 2 variétés
|
||||
r = client.get(f"/api/plants/{plant_id}")
|
||||
varieties = r.json().get("varieties", [])
|
||||
assert len(varieties) == 2
|
||||
assert {v["variete"] for v in varieties} == {"Roma", "Andine Cornue"}
|
||||
|
||||
# Supprimer une variété
|
||||
client.delete(f"/api/plants/{plant_id}/varieties/{vid1}")
|
||||
r = client.get(f"/api/plants/{plant_id}")
|
||||
assert len(r.json()["varieties"]) == 1
|
||||
|
||||
|
||||
def test_get_plant(client):
|
||||
|
||||
Reference in New Issue
Block a user