26 lines
1.2 KiB
Python
26 lines
1.2 KiB
Python
def test_create_planting(client):
|
|
g = client.post("/api/gardens", json={"nom": "Potager", "type": "plein_air"}).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
|
|
})
|
|
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/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
|
|
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/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
|