-
Notifications
You must be signed in to change notification settings - Fork 393
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add an option to remove unused requests from cassette #763
Conversation
Introduce the `drop_unused_requests` option (False by default). If True, it will force the `Cassette` saving operation with only played old interactions and new ones if they exist. As a result, unused old requests are dropped. Add `_old_interactions`, `_played_interactions` and `_new_interactions()`. The `_old_interactions` are previously recorded interactions loaded from Cassette files. The `_played_interactions` is a set of old interactions that were marked as played. A new interaction is a tuple (request, response) in `self.data` that is not in `_old_interactions` list.
LGTM 🚀 @danielnsilva can you fix some lint erros? |
936b846
to
d64cdd3
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #763 +/- ##
==========================================
+ Coverage 89.81% 92.38% +2.56%
==========================================
Files 26 27 +1
Lines 1738 1864 +126
Branches 311 249 -62
==========================================
+ Hits 1561 1722 +161
+ Misses 141 95 -46
- Partials 36 47 +11 ☔ View full report in Codecov by Sentry. |
@hartwork can you help review this pull request? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@danielnsilva thanks for the adjustments! 👍
This PR adds an option to remove previously recorded interactions if they are not used. I believe this feature can address the issue discussed in #208. We don't need to focus on ignoring all requests in the cassette file, but instead, we can write to file only replayed interactions and new ones. If no previous request is used, VCR will save only new interactions.
There is a similar feature in Ruby VCR.
Replaces #677