- Home
- Skills
- Affaan M
- Everything Claude Code
- Django Tdd
django-tdd_skill
- JavaScript
46.5k
GitHub Stars
1
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill affaan-m/everything-claude-code --skill django-tdd- SKILL.md20.4 KB
Overview
This skill teaches test-driven development for Django projects using pytest-django, factory_boy, and tools for testing Django REST Framework APIs. It packages practical setup, fixtures, factories, and example tests to speed up building reliable model, view, serializer, and API tests. Follow the red-green-refactor workflow and the provided configs to get fast, repeatable tests with coverage and mocked external behavior.
How this skill works
The skill provides ready-to-use pytest configuration, test settings, and shared fixtures to run tests in-memory and skip migrations for speed. It includes factory_boy factories for models, example model/view/serializer/API tests, and patterns for authentication, API client use, and coverage reporting. Use the samples to adopt TDD: write a failing test, implement minimal code, then refactor while keeping tests green.
When to use it
- Starting a new Django app and enforcing TDD
- Implementing or testing Django REST Framework endpoints
- Building repeatable model, view, and serializer tests
- Setting up fast CI-friendly test infrastructure with pytest
- Adding factory_boy-based test data and mocking external services
Best practices
- Use the red-green-refactor cycle: write failing tests first, implement minimal logic, then refactor
- Run tests with --reuse-db and --nomigrations for faster iterations in CI and locally
- Prefer factory_boy factories and create_batch for realistic, maintainable test data
- Use lightweight test settings: in-memory SQLite, MD5 password hasher, and disabled migrations for speed
- Isolate external work with mocking and set Celery to eager in tests to avoid background complexity
Example use cases
- TDD for user registration: write serializer and view tests before implementing registration logic
- API contract tests for Product endpoints: assert list, retrieve, create, update, and permission behavior
- Model invariants: validate price/stock rules and manager methods using factories
- View integration tests: assert template context, redirects for unauthenticated users, and form submissions
- CI pipeline: run pytest with coverage reporting and html output to track test health
FAQ
Use in-memory SQLite, disable migrations, use MD5 password hasher, and run pytest with --reuse-db to avoid recreating the database each run.
When should I use factories vs fixtures?
Prefer factory_boy for reusable, composable test data and create fixtures for cross-cutting concerns like authenticated clients or timezone settings.