Claude-skill-registry fastapi-integration-testing
install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/fastapi-integration-testing" ~/.claude/skills/majiayu000-claude-skill-registry-fastapi-integration-testing && rm -rf "$T"
manifest:
skills/data/fastapi-integration-testing/SKILL.mdsource content
FastAPI Integration Testing Skill
This skill provides patterns, templates, and guides for writing robust integration tests for your FastAPI application.
Core Concepts
The approach is centered around
pytest and uses:
- A real database (SQLite by default) for data-dependent tests.
- Transaction-based cleanup to ensure test isolation.
- FastAPI's
for making requests to the application.TestClient - Fixtures for setting up test context (like database sessions and authenticated clients).
- Factories for generating test data.
Getting Started: The Workflow
-
Setup Your Test Environment: Configure your
to manage the test database and provide aconftest.py
.TestClient- See:
references/setup.md - Template:
assets/conftest_template.py
- See:
-
Write Your First Test: Create a test file and write a simple test for a public endpoint.
- See:
references/testing_endpoints.md - Template:
assets/test_api_template.py
- See:
Advanced Testing Scenarios
Once you have the basic setup, you can tackle more complex scenarios.
Testing Protected Endpoints
To test endpoints that require authentication, create a fixture that provides a pre-authenticated client.
- Guide:
references/authentication.md
Testing File Uploads
Learn how to use the
TestClient to simulate file uploads in your tests.
- Guide:
references/file_uploads.md
Verifying Error Responses
Ensure your application returns correct and informative errors for bad requests or missing resources.
- Guide:
references/error_responses.md
Generating Test Data
Use the factory pattern to easily create test data for your models. This is highly recommended for complex applications.
- Guide:
references/factories.md