"""Tests for task CRUD API endpoints.""" from app.models import Task def test_update_task(client, db): """Create a task, update it, verify changes persisted.""" # 1. Create a task response = client.post("/api/tasks", json={ "title": "Initial Task", "description": "Initial description", "priority": 3 }) assert response.status_code == 200 task_id = response.json()["task_id"] # 2. Update title, description, and priority update_data = { "title": "Updated Task", "description": "Updated description", "priority": 1 } response = client.put(f"/api/tasks/{task_id}", json=update_data) # 3. Assert success assert response.status_code == 200 assert response.json()["status"] == "success" # 4. Verify in DB task = db.query(Task).filter(Task.id == task_id).first() assert task.title == "Updated Task" assert task.description == "Updated description" assert task.priority == 1