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:
28
backend/tests/test_tasks.py
Normal file
28
backend/tests/test_tasks.py
Normal file
@@ -0,0 +1,28 @@
|
||||
def test_create_task(client):
|
||||
r = client.post("/api/tasks", json={"titre": "Arroser les tomates", "priorite": "haute"})
|
||||
assert r.status_code == 201
|
||||
assert r.json()["statut"] == "a_faire"
|
||||
|
||||
|
||||
def test_list_tasks(client):
|
||||
client.post("/api/tasks", json={"titre": "Tâche 1"})
|
||||
client.post("/api/tasks", json={"titre": "Tâche 2"})
|
||||
r = client.get("/api/tasks")
|
||||
assert r.status_code == 200
|
||||
assert len(r.json()) == 2
|
||||
|
||||
|
||||
def test_filter_tasks_by_statut(client):
|
||||
client.post("/api/tasks", json={"titre": "À faire", "statut": "a_faire"})
|
||||
client.post("/api/tasks", json={"titre": "Fait", "statut": "fait"})
|
||||
r = client.get("/api/tasks?statut=a_faire")
|
||||
assert r.status_code == 200
|
||||
assert all(t["statut"] == "a_faire" for t in r.json())
|
||||
|
||||
|
||||
def test_update_task_statut(client):
|
||||
r = client.post("/api/tasks", json={"titre": "À faire"})
|
||||
id = r.json()["id"]
|
||||
r2 = client.put(f"/api/tasks/{id}", json={"titre": "À faire", "statut": "fait"})
|
||||
assert r2.status_code == 200
|
||||
assert r2.json()["statut"] == "fait"
|
||||
Reference in New Issue
Block a user