Backend Tests¶
Backend tests use pytest with pytest-django and run against an in-memory SQLite database (no external services required).
Setup¶
Install test dependencies:
Running Tests¶
Or, since DJANGO_SETTINGS_MODULE is configured in pyproject.toml:
With Coverage¶
Test Configuration¶
pyproject.toml— Contains[tool.pytest.ini_options]with the test settings moduleconftest.py— Sets required environment variables before Django loadsconfig/settings_test.py— Overrides the database to SQLite and enables eager Celery execution
Test Structure¶
core/tests/
├── __init__.py
├── test_models.py # Model creation, string representations, deletion
├── test_serializers.py # Serializer round-trip validation
└── test_views.py # API endpoint tests with mocked auth
Writing New Tests¶
- Add tests to the appropriate file in
core/tests/ - Use Django's
TestCaseclass for database tests - Mock external services (Supabase, AI APIs) — never make real API calls in tests
- Run tests locally before submitting a PR