Keboola VCR
raw JSON → 0.5.0 verified Fri May 01 auth: no python
A library for recording, sanitizing, and validating HTTP and database interactions for Keboola component tests using VCR-based cassettes. Version 0.5.0 adds DB VCR support for recording/replaying database interactions. Regular releases, active development.
pip install keboola-vcr Common errors
error ModuleNotFoundError: No module named 'keboola_vcr' ↓
cause Library not installed or installed incorrectly.
fix
Run
pip install keboola-vcr to install. error ImportError: cannot import name 'VCR' from 'keboola_vcr' ↓
cause The old import path is removed in newer versions.
fix
Use
from keboola_vcr import KeboolaVcr. error TypeError: __init__() missing 1 required positional argument: 'cassette_library_dir' ↓
cause KeboolaVcr requires cassette_library_dir.
fix
Pass
cassette_library_dir='path/to/cassettes' when creating KeboolaVcr instance. Warnings
breaking Version 0.2.0 introduced memory usage improvements and sanitizer dedup; older cassettes may need regeneration. ↓
fix Regenerate cassettes by deleting them and re-running tests with record_mode='all'.
deprecated The old import path `from keboola_vcr import VCR` is deprecated in favor of `KeboolaVcr` since v0.1.0. ↓
fix Use `from keboola_vcr import KeboolaVcr`.
gotcha DbVcr requires SQLAlchemy and a database engine; it does not auto-detect database type. ↓
fix Manually create an SQLAlchemy engine and pass it to DbVcr.
Imports
- KeboolaVcr wrong
from keboola_vcr import VCRcorrectfrom keboola_vcr import KeboolaVcr - DbVcr wrong
from keboola_vcr import DbVcrcorrectfrom keboola_vcr.db import DbVcr - KeboolaVcrCassette wrong
from keboola_vcr import KeboolaVcrCassettecorrectfrom keboola_vcr.cassette import KeboolaVcrCassette
Quickstart
from keboola_vcr import KeboolaVcr
vcr = KeboolaVcr(
cassette_library_dir='cassettes',
record_mode='once',
sanitizers=['KBC::ComponentConfig::%s::#token']
)
with vcr.use_cassette('test_get_users.yaml') as cassette:
# Your HTTP calls go here, they will be recorded/replayed
pass