django-tdd
Django testing strategies with pytest-django, TDD methodology, factory_boy, mocking, coverage, and testing Django REST Framework APIs.
npx skills add mturac/everything-openai-codex --skill django-tdd --agent codex
Same command for any agent — swap --agent for claude-code, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
What it does
Guides an AI agent to apply test-driven development practices to Django projects, covering pytest-django setup, Django REST Framework testing, and factory-based test data creation. It outlines a Red-Green-Refactor workflow, infrastructure setup, fixtures, factories, and test patterns for models, views, and DRF APIs, plus examples for mocking external services.
How it works
- When to Activate lists scenarios like writing new Django apps, implementing DRF APIs, testing models/views/serializers, and setting up testing infra.
- Provides a Red-Green-Refactor cycle with example code illustrating failing tests, creating models or factories, and refactoring while keeping tests green.
- Setup section includes pytest configuration (pytest.ini), test settings (config/settings/test.py), and conftest.py with fixtures for timezone, users, authenticated clients, and API clients.
- Factory Boy section shows factories for User, Category, Product, and a post-generation hook for tags, plus usage examples for creating products and batches.
- Model Testing includes tests for User and Product models, slug generation, validation, active manager, stock management, and error handling.
- View Testing covers Django view tests for listing, detail, login requirements, authenticated creation, and POST creation flow.
- DRF API Testing includes serializer tests and API viewset tests for listing, retrieving, creating (auth required), updating, deleting, filtering by price, and search.
- Mocking and Patching demonstrates mocking external services (e.g., Stripe) in view tests to simulate successful payments.
When to use it
- Triggered when starting new Django projects or adding DRF APIs.
- Use to set up a comprehensive testing strategy, from unit models to API endpoints, including test data factories and fixtures.
What it can touch
- Files: pytest.ini configuration, DRF serializers, views, and API endpoints under apps.*, tests/, and factories under tests/factories.py.
- Tools declared: codex, copilot, cursor
Caveats
- License noted as MIT.
- The content includes code examples and fixtures that assume specific project structure (e.g., apps.products, config.settings.test) and may require adaptation for a given codebase.
# Django Testing with TDD Test-driven development for Django applications using pytest, factory_boy, and Django REST Framework. ## When to Activate - Writing new Django applications - Implementing Django REST Framework APIs - Testing Django models, views, and serializers - Setting up testing infrastructure for Django projects ## TDD Workflow for Django ### Red-Green-Refactor Cycle ```python # Step 1: RED - Write failing test def test_user_creation(): user = User.objects.create_user(email='test@example.com', password='testpass123') assert user.email == 'test@example.com' assert user.check_password('testpass123') assert not user.is_staff # Step 2: GREEN - Make test pass # Create User model or factory # Step 3: REFACTOR - Improve while keeping tests green ``` ## Setup ### pytest Configuration ```ini # pytest.ini [pytest] DJANGO_SETTINGS_MODULE = config.settings.test testpaths = tests python_files = test_*.py python_classes = Test* python_functions = test_* addopts = --reuse-db --nomigrations --cov=apps --cov-report=html --cov-report=term-missing --strict-markers markers = slow: marks tests as slow integration: marks tests as integration tests ``` ### Test Settings ```python # config/s
- When to Activate
- TDD Workflow for Django
- Red-Green-Refactor Cycle
- Setup
- pytest Configuration
- Test Settings
- conftest.py
- Factory Boy
- Factory Setup
- Using Factories
- Model Testing
- Model Tests
- View Testing
- Django View Testing
Run tests with coverage pytest --cov=apps --cov-report=html --cov-report=term-missing Generate HTML report open htmlcov/index.html
What does the django-tdd skill do?
Django testing strategies with pytest-django, TDD methodology, factory_boy, mocking, coverage, and testing Django REST Framework APIs.
How do I install it?
Run `npx skills add mturac/everything-openai-codex --skill django-tdd --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From mturac/everything-openai-codex, a repository with 84 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
