Write correct Flask tests -- app factory with test config, application context fixtures, database isolation, file uploads, auth testing, error handlers, mock.patch placement, and essential API test patterns
98
99%
Does it follow best practices?
Impact
97%
1.15xAverage score across 5 eval scenarios
Passed
No known issues
Write tests for a Flask task tracking application that includes both API endpoints and CLI commands. The app uses the factory pattern and SQLite.
id, username, email, password_hash, is_admin (boolean, default False)id, title, description, status (string: 'todo', 'in_progress', 'done', 'archived'), priority (string: 'low', 'medium', 'high'), assignee_id (FK to User, nullable), created_by_id (FK to User), created_at, updated_atPOST /auth/login -- log in (username, password)GET /api/tasks -- list tasks (authenticated, supports ?status= and ?priority= query params)POST /api/tasks -- create task (authenticated)GET /api/tasks/<id> -- get task detail (authenticated)PATCH /api/tasks/<id> -- update task fields (authenticated, creator or assignee only)PATCH /api/tasks/<id>/status -- update task status (authenticated, must follow valid transitions: todo->in_progress->done->archived)DELETE /api/tasks/<id> -- delete task (admin only)flask init-db -- initialize the database schema, prints "Database initialized."flask seed-data -- seed sample tasks and users, prints "Seeded N tasks."flask archive-done --days 30 -- archive tasks that have been 'done' for more than N days, prints "Archived N tasks."All API errors return JSON with the shape {"error": {"message": "...", "code": "..."}}. Custom error handlers are registered for 400, 404, and 500.
Produce test files under tests/ with comprehensive coverage of both the API and CLI commands. Include tests/conftest.py. Assume app code exists; you are only writing the tests.