feat(backend): CRUD variétés, plantations, tâches + tests
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
25
backend/tests/test_plantings.py
Normal file
25
backend/tests/test_plantings.py
Normal file
@@ -0,0 +1,25 @@
|
||||
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()
|
||||
r = client.post("/api/plantings", json={
|
||||
"garden_id": g["id"], "variety_id": v["id"], "quantite": 3
|
||||
})
|
||||
assert r.status_code == 201
|
||||
assert r.json()["statut"] == "prevu"
|
||||
|
||||
|
||||
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()
|
||||
client.post("/api/plantings", json={"garden_id": g["id"], "variety_id": v["id"]})
|
||||
r = client.get("/api/plantings")
|
||||
assert r.status_code == 200
|
||||
assert len(r.json()) >= 1
|
||||
|
||||
|
||||
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()
|
||||
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
|
||||
Reference in New Issue
Block a user