atelier-python-testing_skill

This skill helps you implement stub-driven TDD and layer boundary tests for Python applications using pytest.
  • JavaScript

4

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 martinffx/claude-code-atelier --skill atelier-python-testing

  • SKILL.md4.6 KB

Overview

This skill teaches Stub-Driven TDD and layer-boundary testing for Python projects using pytest. It focuses on writing minimal stubs, driving implementation with tests, and testing what crosses component boundaries rather than internal details. It provides patterns for entities, services, repositories, and HTTP routers to keep tests fast, reliable, and focused.

How this skill works

Start by stubbing a function or method signature, write a failing test for the expected behavior, implement the minimal code to make the test pass, then refactor. Tests are organized by layer: entity tests verify domain transformations and validation; service tests orchestrate behavior with mocked dependencies; repository tests run against a test database; router tests exercise request validation and response serialization via a test client. The approach emphasizes testing interactions at boundaries and using mocks only for external dependencies.

When to use it

  • When practicing Test-Driven Development on new features or bug fixes
  • When deciding which behavior belongs to which layer (entity/service/repository/router)
  • When you need fast unit tests for business logic and slower integration tests for data access or HTTP endpoints
  • When you want to reduce brittle tests by avoiding internal implementation assertions
  • When designing APIs where request/response transformation and status codes must be validated

Best practices

  • Follow Stub → Test → Implement → Refactor: start with a no-op stub, write a focused test, implement minimal behavior, then clean up
  • Test only what crosses layer boundaries: validate transformations, orchestration, persistence, and HTTP contracts rather than internals
  • Mock dependencies at service level to verify orchestration and interactions, but use a real test database for repository tests
  • Keep router tests at the HTTP layer using a TestClient to assert status codes and payloads
  • Organize tests by unit/integration boundaries and share fixtures in a central conftest to avoid duplication

Example use cases

  • Entity tests for from_request/to_response transformations and domain business rules (e.g., apply_discount)
  • Service tests that assert calls to repositories and error handling using unittest.mock or similar
  • Repository integration tests against an in-memory or test database to validate CRUD and mapping logic
  • Router endpoint tests with TestClient to verify validation, status codes, and serialized responses
  • TDD flow when introducing a new API endpoint: stub handler, write router test, implement service, then repository

FAQ

No. Repository tests should use a test database (in-memory or a dedicated test instance) to validate queries and mappings; mocking hides real persistence behavior.

When is it appropriate to mock dependencies?

Mock dependencies at the service layer to test orchestration and interaction counts. Avoid mocking inside entities and repository internals; instead test those layers directly with real inputs or a test DB.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational
atelier-python-testing skill by martinffx/claude-code-atelier | VeilStrat