Skip to main content

Convert binary Python VCR cassette responses to human-readable strings.

Project description

VCRPY Binary Converter

Convert binary Python VCR cassette responses to human-readable strings.

Build Status Coverage Status PyPi Licence

Showcase

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

# Homebrew install
brew tap justintime50/formulas
brew install vcrpy-bincon

# Pip install
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:

  1. null fields in cassettes may get replaced with nothing and become empty
  2. 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
  3. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vcrpy_bincon-0.3.0.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vcrpy_bincon-0.3.0-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file vcrpy_bincon-0.3.0.tar.gz.

File metadata

  • Download URL: vcrpy_bincon-0.3.0.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for vcrpy_bincon-0.3.0.tar.gz
Algorithm Hash digest
SHA256 a32eb0c1d82fc0f0f76e8a3cf5272c8c46ff576285c438367037dfc70511a790
MD5 47b948ab0799b810ec2bef1003061061
BLAKE2b-256 916464c3310efad467e7685cf3056d9743af0247fda19f7d9f8db6142d2421d3

See more details on using hashes here.

File details

Details for the file vcrpy_bincon-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: vcrpy_bincon-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for vcrpy_bincon-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2476bf335fae228952c170e27f731dfe05344b7db5548fbee6b1a9a09dc8cf5d
MD5 ca930cb6fa2f953241e8c459b2edc3f7
BLAKE2b-256 aa6ff976be76cc0aab39e946318b5f6fc15ad79651830252377f6f76ab3702a5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page