avant codex
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user