This skill helps you write and maintain Keboola Python component tests, covering datadir, unit, and integration tests with robust mocks.
npx playbooks add skill keboola/ai-kit --skill test-component
Three levels, in priority order:
Use VCR (keboola.datadirtest) when the component makes external HTTP calls:
Use mocks (unittest.mock) when:
keboola.datadirtest>=2.0.0 to pyproject.toml dev dependencies, run uv sync -Utests/test_functional.py from component-developer:component-defaults assetssrc/component.py, src/configuration.py, component_config/configSchema.json) and build tests/setup/configs.json — see [vcr-configs-format.md](references/vcr-configs-format.md)secrets.json (verify it's in .gitignore)uv run python -m keboola.datadirtest scaffold [--secrets secrets.json] [--chain-state].gitignore, Dockerfile (COPY tests/ tests), and push.yml (use python -m pytest)python -m pytest locally and in DockerSee [vcr-quickstart.md](references/vcr-quickstart.md) for all scaffold commands. See [vcr-troubleshooting.md](references/vcr-troubleshooting.md) for common failures.
| File | When to read |
|------|-------------|
| references/datadir-tests.md | Setting up datadir tests — directory structure, config.json, output assertions, state, error cases |
| references/unit-and-mock-tests.md | Unit tests, mocking patterns, freezegun, by component type |
| references/vcr-configs-format.md | Building configs.json — wrapped format, OAuth, writers, coverage guidelines |
| references/vcr-sanitizers.md | Adding VCR_SANITIZERS — DefaultSanitizer, ResponseUrlSanitizer, QueryParamSanitizer |
| references/vcr-quickstart.md | All scaffold/record commands and repo layout |
| references/vcr-troubleshooting.md | Common VCR failures and fixes |
| references/vcr-debug-from-platform.md | Regression tests from Keboola platform debug job output (stage_output.zip) |
Weekly roundup of top Claude Code skills, MCP servers, and AI coding tips.