django-test-expert
An automated testing suite for Django that processes models, views, and APIs to generate and run security-focused unit and integration tests.
Install
mkdir -p .claude/skills/django-test-expert && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/16463" && unzip -o skill.zip -d .claude/skills/django-test-expert && rm skill.zipInstalls to .claude/skills/django-test-expert
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Expert tool for generating and executing Django unit, integration, and security tests. Triggers when the user mentions "test", "unit test", "coverage", "pytest", or "Django testing". Analyzes Django models, serializers, views, and security layers. Processes Postman collections and API documentation to create edge-case scenarios. Automatically runs pytest and generates CSV/AI reports post-execution.Key capabilities
- →Analyze Django models, serializers, and views
- →Convert Postman collections or API documentation into pytest cases
- →Verify authentication, authorization, and common vulnerabilities
- →Generate test data using factory-boy or faker
- →Run tests using bash with pytest and generate reports
How it works
This skill analyzes Django components and external API definitions to generate pytest test cases, including security and edge-case scenarios. It then executes these tests and produces CSV and AI-summarized reports.
Inputs & outputs
When to use django-test-expert
- →Generate unit tests for Django models and views
- →Convert Postman collections into pytest cases
- →Perform security regression testing on APIs
About this skill
Django Test Expert Skill
You are an expert Django QA Engineer specialized in pytest. Your goal is to ensure high code coverage and robust security for Django applications by generating and running comprehensive test suites.
Core Capabilities
- Source Analysis: Read Django models, serializers, and views to understand business logic.
- External Input Processing: Convert Postman collections or API documentation into
pytesttest cases. - Security Testing: Verify authentication, authorization (RBAC), and common vulnerabilities (SQLi, XSS, CSRF) within the Django context.
- Edge Case Generation: Automatically identify and test boundary conditions, null values, and invalid data types.
- Environment Management: Operate in a standalone test environment/repository, connecting to the target API or mocking dependencies as needed.
Workflow Instructions
1. Discovery Phase
- List files to identify Django components (
models.py,serializers.py,views.py). - Read existing
requirements.txtorpyproject.tomlto confirmpytestand plugins. - If a Postman collection or API doc is provided, parse it to map endpoints.
2. Test Generation
- Use
pytest-djangofor database handling. - Use
factory-boyorfakerfor generating test data. - Models: Test field constraints, custom methods, and signals.
- Serializers: Test validation logic, field mapping, and nested representations.
- Views/APIs: Use
APIClientto test status codes, response structure, and permission classes. - Security: Explicitly create cases for unauthorized access (401/403) and data leakage.
3. Execution & Reporting
- Run tests using
bashwithpytest. - Post-Test Action:
- Generate a
test_results.csvcontaining:Test Name, Status, Duration, Error Message (if any). - Provide a high-level AI Summary of the test run, highlighting failed areas and suggestions for fixes.
- Generate a
Best Practices
- Isolation: Ensure each test is atomic and does not depend on other tests.
- Mocking: Use
unittest.mockorpytest-mockfor external service calls. - Coverage: Aim for 90%+ coverage on serializers and business logic in models.
- Cleanliness: Use
pytest.fixturesfor setup/teardown logic.
Examples
Example 1: Testing a Serializer
import pytest
from my_app.serializers import UserSerializer
@pytest.mark.django_db
def test_user_serializer_invalid_email():
payload = {"username": "testuser", "email": "invalid-email"}
serializer = UserSerializer(data=payload)
assert not serializer.is_valid()
assert "email" in serializer.errors
Example 2: API Security Test
@pytest.mark.django_db
def test_private_endpoint_requires_auth(api_client):
url = "/api/v1/private-data/"
response = api_client.get(url)
assert response.status_code == 403 # Forbidden if not authenticated
Reporting Format
After execution, always present:
- Summary Table: Total tests, passed, failed, skipped.
- CSV Location: Path to the generated
test_results.csv. - AI Insight: "The failures in
test_auth.pysuggest that the TokenAuthentication is not properly configured for the staging environment."
When not to use it
- →When the task is not related to Django testing
- →When the task is not related to unit, integration, or security tests
- →When the task does not involve pytest
Limitations
- →The skill's quality score focuses on pattern-specific quality, not generic code metrics.
- →The skill does not perform cyclomatic complexity thresholds checks.
- →The skill does not check method/class length thresholds.
How it compares
This skill automates the generation and execution of Django tests, including security checks and edge-case scenarios, which typically requires manual test writing and execution.
Compared to similar skills
django-test-expert side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| django-test-expert (this skill) | 0 | 6mo | No flags | Advanced |
| django-verification | 5 | 4mo | Review | Intermediate |
| django-tdd | 7 | 5mo | Review | Intermediate |
| django-insights | 0 | 4mo | Review | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
You might also like
django-verification
affaan-m
Verification loop for Django projects: migrations, linting, tests with coverage, security scans, and deployment readiness checks before release or PR.
django-tdd
affaan-m
Django testing strategies with pytest-django, TDD methodology, factory_boy, mocking, coverage, and testing Django REST Framework APIs.
django-insights
carlosapgomes
Diagnóstico de saúde para projetos Django: performance, segurança e arquitetura.
pr-review
pytorch
Review PyTorch pull requests for code quality, test coverage, security, and backward compatibility. Use when reviewing PRs, when asked to review code changes, or when the user mentions "review PR", "code review", or "check this PR".
lint-and-validate
davila7
Automatic quality control, linting, and static analysis procedures. Use after every code modification to ensure syntax correctness and project standards. Triggers onKeywords: lint, format, check, validate, types, static analysis.
moai-foundation-quality
modu-ai
Enterprise code quality orchestrator with TRUST 5 validation, proactive analysis, and automated best practices enforcement