Giter VIP home page Giter VIP logo

vcrpy-cassette-mgr's Introduction

VCR.py Cassette Manager Extension for Visual Studio Code

GitHub Visual Studio Marketplace

Easily open or delete vcrpy cassettes within your tests. Bulk delete cassettes from the current file or the entire workspace.

features-overview

Features

  • CodeLens buttons above vcr decorators to open or delete cassettes
  • Commands:
    • Delete Cassettes in Current File
    • Delete Cassettes in Workspace

Requirements

  • Python language mode must be selected for the active file.
  • Only scans for cassettes in files that start with test_. (can be changed with testFileNameStartsWith setting)
  • Cassette names must match their function name.
  • Only yaml cassettes are supported.

Commands

Delete Cassettes in Current File

Deletes all cassettes in the current file. Asks for confirmation before deleting.

Delete Cassettes in Workspace

Deletes all cassettes in the current workspace. Asks for confirmation before deleting.

Extension Settings

  • vcrpy-cassette-mgr.testFileNameStartsWith: The prefix of your test files. This is used to determine which files are test files and which are not. Defaults to test_.
  • vcrpy-cassette-mgr.cassetteDirectoryName: The name of the directory where your cassettes are stored. The directory will be automatically located in any subdirectories of your workspace. Defaults to cassettes.
  • vcrpy-cassette-mgr.vcrDecoratorMatchText: The text that should be matched to determine if a line is a vcrpy decorator. The default is for pytest, but can be changed to match any decorator such as @vcr.use_cassette. Defaults to @pytest.mark.vcr.
  • vcrpy-cassette-mgr.deleteConfirmation: Choose when to confirm before deleting cassettes.. Defaults to Workspace, Current File, Tests.
  • vcrpy-cassette-mgr.cassetteButtonOpen: Show a button in the editor to open the cassette file. Defaults to true.
  • vcrpy-cassette-mgr.cassetteButtonDelete: Show a button in the editor to delete the cassette file. Defaults to true.

Planned Features

  • Add the ability to detect vcr record mode (from pytest config or python.testing.pytestArgs vs code setting override) and change it from the status bar.
  • Add the ability to detect cassette folder (from pytest config).

Known Issues

None at this time.

Release Notes

[1.1.3] - 2024-03-21

Bug Fixes

  • Fixed multiple cassettes found when tests have same base name #2

[1.1.2] - 2024-03-21

Added planned features section to README.

Bug Fixes

  • Fixed missing cassettes when @pytest.mark.parametrize decorator is used #1

[1.1.0] - 2023-12-20

New features

  • New configuration options:
    • vcrpy-cassette-mgr.deleteConfirmation
    • vcrpy-cassette-mgr.cassetteButtonOpen
    • vcrpy-cassette-mgr.cassetteButtonDelete
  • Status bar:
    • Shows the number of cassettes in the current file
    • Warns if the cassette directory is not found
    • Provides quick access to delete commands, rescan directory, and configure extension

[1.0.0] - 2023-12-15

Initial release

  • CodeLens buttons above vcr decorators to open or delete cassettes
  • Commands:
    • Delete Cassettes in Current File
    • Delete Cassettes in Workspace

vcrpy-cassette-mgr's People

Contributors

pdjohntony avatar

Watchers

 avatar

vcrpy-cassette-mgr's Issues

Multiple cassettes found when tests have same base name

This issue is a result of fixing #1 in v1.1.2.

Now that cassette searching can match multiple files for a single test, if two tests share the same base name, the wrong cassette can be matched for a test.

Here is the new cassette matching code:

const matchingFiles = files.filter(file => file.startsWith(`${vcrDecorator.vcrTestName}`) && file.endsWith('.yaml'));

Here are some example test names:

test_msteams_service_emergency_address_create
test_msteams_service_emergency_address_create_without_latlon

These overlapping names will cause test_msteams_service_emergency_address_create to also match the cassettes for test_msteams_service_emergency_address_create_without_latlon.

This is also causing an issue during the deleteCassettesCurrentFile command. Where the same cassettes can become duplicated in the currentFileCassettesArray and will cause subsequent deletion failures.

No cassette found when test function is args are multiline

No cassette is found for the following example:

@pytest.mark.vcr
@pytest.mark.parametrize(
    "field, value",
    [
        ("addressDescription", "Fake Address"),
        ("addressDescription", ""),
        ("name", "Fake Location"),
        ("name", ""),
    ],
)
def test_msteams_service_emergency_location_update_bad_raises(
    mstsc, field, value, emer_addr
):

I think its due to the (args) being multiline. Need to investigate further.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.