CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl-labs/flask-testing

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

1.15x
Quality

99%

Does it follow best practices?

Impact

97%

1.15x

Average score across 5 eval scenarios

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

task.mdevals/scenario-1/

Blog API Tests

Write tests for a Flask blog API. The app uses the factory pattern and SQLite. The models are:

  • Post: id, title (string), body (text), author_id (FK to User), created_at (datetime), published (boolean, default False)
  • Comment: id, post_id (FK to Post), author_id (FK to User), body (text), created_at (datetime)
  • Tag: id, name (string, unique), with a many-to-many relationship to Post

The API endpoints are:

  • GET /api/posts -- list published posts with their tags
  • POST /api/posts -- create a new post (requires authentication)
  • GET /api/posts/<id> -- retrieve a single post
  • PUT /api/posts/<id> -- update a post (author only, requires authentication)
  • DELETE /api/posts/<id> -- delete a post (author only, requires authentication)
  • GET /api/posts/<id>/comments -- list comments for a post
  • POST /api/posts/<id>/comments -- add a comment (requires authentication)
  • GET /api/tags -- list all tags

The app factory is create_app(test_config=None) in app/__init__.py. Database operations use app.db module with init_db() and get_db().

Output

Produce test files under tests/ with comprehensive test coverage for the above endpoints. Include a tests/conftest.py with all necessary fixtures. Assume the models and routes already exist; you are only writing the tests.

evals

scenario-1

criteria.json

task.md

tile.json