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-4/

Recipe Sharing App Tests

Write tests for a Flask recipe sharing application. The app uses the factory pattern, SQLAlchemy, and Flask-Login for authentication.

Models

  • User: id, username (unique), email, password_hash
  • Recipe: id, title, description, ingredients (text), instructions (text), author_id (FK to User), created_at, is_public (boolean, default True)
  • Favorite: id, user_id (FK to User), recipe_id (FK to Recipe), created_at

Endpoints

  • POST /auth/register -- register a new user (username, email, password)
  • POST /auth/login -- log in (username, password), returns session
  • POST /auth/logout -- log out
  • GET /api/recipes -- list public recipes
  • POST /api/recipes -- create recipe (authenticated)
  • GET /api/recipes/<id> -- get recipe detail
  • PUT /api/recipes/<id> -- update recipe (author only)
  • DELETE /api/recipes/<id> -- delete recipe (author only)
  • POST /api/recipes/<id>/favorite -- favorite a recipe (authenticated)
  • DELETE /api/recipes/<id>/favorite -- unfavorite (authenticated)
  • GET /api/users/me/favorites -- list my favorites (authenticated)

The app factory is create_app(test_config=None) in app/__init__.py. It uses SQLAlchemy with db.create_all() for schema setup.

Output

Produce test files under tests/ with comprehensive test coverage. Include tests/conftest.py with all fixtures. Assume the app code already exists; you are only writing the tests.

evals

tile.json