avant codex

This commit is contained in:
2026-02-22 15:05:40 +01:00
parent fed449c784
commit 20af00d653
291 changed files with 51868 additions and 424 deletions
+3 -3
View File
@@ -1,6 +1,6 @@
def test_create_planting(client):
g = client.post("/api/gardens", json={"nom": "Potager", "type": "plein_air"}).json()
v = client.post("/api/varieties", json={"nom_commun": "Tomate"}).json()
v = client.post("/api/plants", json={"nom_commun": "Tomate"}).json()
r = client.post("/api/plantings", json={
"garden_id": g["id"], "variety_id": v["id"], "quantite": 3
})
@@ -10,7 +10,7 @@ def test_create_planting(client):
def test_list_plantings(client):
g = client.post("/api/gardens", json={"nom": "Potager", "type": "plein_air"}).json()
v = client.post("/api/varieties", json={"nom_commun": "Tomate"}).json()
v = client.post("/api/plants", json={"nom_commun": "Tomate"}).json()
client.post("/api/plantings", json={"garden_id": g["id"], "variety_id": v["id"]})
r = client.get("/api/plantings")
assert r.status_code == 200
@@ -19,7 +19,7 @@ def test_list_plantings(client):
def test_add_planting_event(client):
g = client.post("/api/gardens", json={"nom": "Potager", "type": "plein_air"}).json()
v = client.post("/api/varieties", json={"nom_commun": "Tomate"}).json()
v = client.post("/api/plants", json={"nom_commun": "Tomate"}).json()
p = client.post("/api/plantings", json={"garden_id": g["id"], "variety_id": v["id"]}).json()
r = client.post(f"/api/plantings/{p['id']}/events", json={"type": "arrosage", "note": "Bien arrosé"})
assert r.status_code == 201
+26
View File
@@ -0,0 +1,26 @@
def test_create_plant(client):
r = client.post("/api/plants", json={"nom_commun": "Tomate", "famille": "Solanacées"})
assert r.status_code == 201
assert r.json()["nom_commun"] == "Tomate"
def test_list_plants(client):
client.post("/api/plants", json={"nom_commun": "Tomate"})
client.post("/api/plants", json={"nom_commun": "Courgette"})
r = client.get("/api/plants")
assert r.status_code == 200
assert len(r.json()) == 2
def test_get_plant(client):
r = client.post("/api/plants", json={"nom_commun": "Basilic"})
id = r.json()["id"]
r2 = client.get(f"/api/plants/{id}")
assert r2.status_code == 200
def test_delete_plant(client):
r = client.post("/api/plants", json={"nom_commun": "Test"})
id = r.json()["id"]
r2 = client.delete(f"/api/plants/{id}")
assert r2.status_code == 204
+36
View File
@@ -0,0 +1,36 @@
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
+18
View File
@@ -0,0 +1,18 @@
def test_create_tool(client):
r = client.post("/api/tools", json={"nom": "Bêche", "categorie": "beche"})
assert r.status_code == 201
assert r.json()["nom"] == "Bêche"
def test_list_tools(client):
client.post("/api/tools", json={"nom": "Outil1"})
r = client.get("/api/tools")
assert r.status_code == 200
assert len(r.json()) >= 1
def test_delete_tool(client):
r = client.post("/api/tools", json={"nom": "Test"})
id = r.json()["id"]
r2 = client.delete(f"/api/tools/{id}")
assert r2.status_code == 204
+11 -8
View File
@@ -1,26 +1,29 @@
"""Tests de l'ancien endpoint /api/varieties — maintenant redirigé vers /api/plants."""
def test_create_variety(client):
r = client.post("/api/varieties", json={"nom_commun": "Tomate", "famille": "Solanacées"})
r = client.post("/api/plants", json={"nom_commun": "Tomate", "famille": "Solanacées"})
assert r.status_code == 201
assert r.json()["nom_commun"] == "Tomate"
def test_list_varieties(client):
client.post("/api/varieties", json={"nom_commun": "Tomate"})
client.post("/api/varieties", json={"nom_commun": "Courgette"})
r = client.get("/api/varieties")
client.post("/api/plants", json={"nom_commun": "Tomate"})
client.post("/api/plants", json={"nom_commun": "Courgette"})
r = client.get("/api/plants")
assert r.status_code == 200
assert len(r.json()) == 2
def test_get_variety(client):
r = client.post("/api/varieties", json={"nom_commun": "Basilic"})
r = client.post("/api/plants", json={"nom_commun": "Basilic"})
id = r.json()["id"]
r2 = client.get(f"/api/varieties/{id}")
r2 = client.get(f"/api/plants/{id}")
assert r2.status_code == 200
def test_delete_variety(client):
r = client.post("/api/varieties", json={"nom_commun": "Test"})
r = client.post("/api/plants", json={"nom_commun": "Test"})
id = r.json()["id"]
r2 = client.delete(f"/api/varieties/{id}")
r2 = client.delete(f"/api/plants/{id}")
assert r2.status_code == 204