Convert binary Python VCR cassette responses to human-readable strings.
Project description
VCR cassette responses often get saved as binary instead of a human-readable string. This makes inspecting the content difficult and depending on the VCR configuration, cassette matching impossible. This tool takes in a cassette directory and converts all binary response interactions to a human-readable string before dumping the yaml back to the cassette file. This allows for devs to properly inspect their cassette content while retaining all the original data - super useful if switching your VCR config from binary to strings.
# Takes something like the following from a vcrpy cassette:
interactions:
response:
body:
string: !!binary |
H4sIAAAAAAAAA4yRT0vEMBDFv0rJ1RaS/rc3xYJCVxZ3XfBUps0UI21a0lTUZb+7k0ovnvY4j997
byY5MyVZwUCaOm8kZEkEaZwJIRChyXIedk2eAEb8VjCfjc0Htpb4OykNzjNJrUGwKGtwcsjDKBA8
4OlRZEWSFFF0w3nBOYHLJK8DNQxISFmdng6uYBwm0N+s0Evf+2y2BtEKAqIsjb2V8vYv5aEq37z7
6vTANiYkxvmVJTPblbv94xo4W9qDlOMzDT9qclG5EGkQC56uhYu2xnleHT69jxq3dhxA9dswjNLl
TGaUS2vVqJ0ZjFFo6g5a1a/Nfyy9lpKorQKyW7OgzzqUaKCvLXzV7hO2+2i7f9onGtWpFlzHzIrz
5fILAAD//wMAxbg+BbcBAAA=
# And turns it into this:
interactions:
response:
body:
string: '{"id": "adr_8bda753a647111eeab7802fb85ae3091", "object": "Address",
"created_at": "2023-10-06T17:55:33+00:00", "updated_at": "2023-10-06T17:55:33+00:00",
"name": "ELVIS", "company": null, "street1": "3764 ELVIS PRESLEY BLVD", "street2":
"", "city": "MEMPHIS", "state": "TN", "zip": "38116-4106", "country": "US",
"phone": null, "email": null, "mode": "production", "carrier_facility": null,
"residential": true, "federal_tax_id": null, "state_tax_id": null, "verifications":
{}}'
Install
# Install tool
pip3 install vcrpy_bincon
# Install locally
just install
Usage
# Specify the directory where your cassette files live as the first param
vcrpy-bincon tests/cassettes
Known Side Effects
Using this tool has a couple of known (low-impact) side effects:
null
fields in cassettes may get replaced with nothing and become empty- Some already human-readable strings may get re-encoded as escaped JSON strings if VCRPY had odd line breaks such as the ending quote on a newline with no other content
- Long URL and other field values may get bumped down a line from its key pair due to the default line length of 80
Development
# Get a comprehensive list of development tools
just --list
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file vcrpy-bincon-0.1.1.tar.gz
.
File metadata
- Download URL: vcrpy-bincon-0.1.1.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 440727c6f56d581d835327513eeffbc9884bf49ff480249de0f71b695e726bd8 |
|
MD5 | 4c83e9d113e4bc26b11618c621ed1f35 |
|
BLAKE2b-256 | be02434f5c0a98e74963e6c47b70fff3571fe1f856b094f3da9a6d641f137f7c |
File details
Details for the file vcrpy_bincon-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: vcrpy_bincon-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 38d2c9c1c00bd861b9dd2ba2ef1693329982e6a413f372b6dadf190f5aedd31a |
|
MD5 | 0ebce72fd909eae160244f9c5c2d2781 |
|
BLAKE2b-256 | f55ec28281786c8f0f163bfaa8f1b2167d694f8104f98346bf3d632d3504d274 |