test-component_skill

This skill helps you write and maintain Keboola Python component tests, covering datadir, unit, and integration tests with robust mocks.
  • Python

7

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 keboola/ai-kit --skill test-component

  • SKILL.md7.7 KB

Overview

This skill is an expert agent for writing and maintaining tests for Keboola Python components. It focuses on datadir tests, unit tests, and integration tests with proper mocking and strong assertions. The goal is to deliver reliable, production-like test coverage that validates component behavior, state management, and output artifacts.

How this skill works

The agent inspects component entrypoints (typically src/component.py), configuration files, and test data to design datadir, unit, and integration tests. It generates datadir test cases that mirror production KBC_DATADIR layouts, writes unit tests for complex logic, and creates integration tests that mock external APIs and validate error handling. It also verifies CSV outputs, manifests, and state persistence.

When to use it

  • When adding a new Keboola component or feature that affects extraction/transformation/loading
  • When refactoring component logic to ensure behavior remains unchanged
  • Before releasing a component update to validate state handling and manifests
  • When onboarding new contributors to provide concrete test examples
  • To reproduce and guard against regressions found in production

Best practices

  • Start with datadir tests as the primary coverage method — mirror the real KBC_DATADIR structure
  • Keep test data realistic but minimal and store expected outputs under tests/data/
  • Mock all external API calls and error scenarios; never use real credentials in tests
  • Write unit tests for transformations, validation, and complex business rules to avoid brittle end-to-end tests
  • Assert on outputs (CSV rows, manifest fields, out/state.json) and cleanup temporary artifacts after tests

Example use cases

  • Create a datadir test for a full load that verifies output CSV, manifest, and out/state.json
  • Add unit tests for a transform_record function to assert type conversions and field mapping
  • Implement an integration test that patches the API client to simulate rate limiting and retries
  • Write incremental-load tests that seed in/state.json and assert only new records are processed
  • Test configuration validation by removing required parameters and asserting raised errors

FAQ

Datadir tests reproduce the production environment exactly, exercise the full component workflow, and validate output files and state—making them the most effective single test type for Keboola components.

How should I mock external services?

Patch the API client classes or HTTP calls using unittest.mock (patch, MagicMock) and return deterministic responses for happy path and error scenarios; do not call real endpoints.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational