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
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.
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.

Basic usage: create a KeboolaVcr instance with sanitizers and use a cassette for recording/replaying HTTP interactions.

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