django-tdd

Configure pytest-django TDD tests for Django models and DRF endpoints.

Updated Sep 13, 2025
One-click install
npx skills add https://github.com/llmh333/employee_management_spring --skill django-tdd-llmh333
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: django-tdd
Source: https://github.com/llmh333/employee_management_spring/tree/main/.gemini/skills/django-tdd
Command: npx skills add https://github.com/llmh333/employee_management_spring --skill django-tdd-llmh333

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Django teams often ship bugs late because core behaviors across models, views, and APIs aren’t verified early and consistently.

Core Features & Use Cases

  • Red-Green-Refactor TDD workflow: Start with failing tests, implement the smallest passing change, then refactor while keeping tests green—useful for adding features incrementally.
  • pytest-django configuration for fast, repeatable test runs: Use settings that speed up CI by disabling migrations, reusing the database, and collecting coverage to maintain quality over time.
  • Model, view, and DRF API testing patterns: Validate business rules, permissions/redirects, serializer validation, and endpoint behavior using fixtures and authenticated clients.
  • Factory Boy + mocking guidance: Generate realistic test data with factories and safely mock external integrations (e.g., payment gateways, email backends) to avoid flaky tests.
  • Example coverage targets and best practices: Keep tests maintainable by focusing assertions, isolating dependencies, and running against the test database only.

Quick Start

Ask the AI to generate a pytest-django TDD test suite for a new Django app’s model validations, HTML views, and DRF endpoints using factory_boy and mocking for external services.

Frequently Asked Questions about django-tdd

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up pytest-django for fast test execution in CI?

Configure pytest-django for fast test execution by disabling migrations, reusing the database across test runs, and using an in-memory database. This setup speeds up CI and ensures repeatable test results for Django applications.

How do I test Django REST Framework endpoints with pytest?

Test DRF endpoints using pytest-django by validating endpoint behavior, serializer validation, and permissions with authenticated clients. Apply factory_boy to generate deterministic test data and isolate API testing fixtures.

What is the best way to mock external dependencies in Django tests?

The best way to mock external dependencies in Django tests is safely mocking external integrations like payment gateways and email backends. This approach avoids flaky tests by isolating external services from your test database.

How to apply TDD workflow to Django model validations?

Apply TDD to Django models using the Red-Green-Refactor workflow: write failing tests for business rules first, implement the smallest passing change, then refactor while keeping tests green to incrementally add model features.

How do I generate realistic test data for Django tests using factory_boy?

Generate realistic test data for Django tests using factory_boy factories to create deterministic model instances. This ensures consistent and reliable test data for validating views, models, and DRF API behaviors.