Closed ekohl closed 8 years ago
That seems reasonable and along the lines of what VCR does.
We'll probably want to be a little careful with how we do this. We'll probably want to make placeholders not a list of dictionaries but instead something a bit more conductive to merging. We might want to do something like:
import collections
Placeholder = collections.namedtuple('Placeholder', ['replace', 'replace_with'])
And then store them as something like
{'<AUTHORIZATION>': Placeholder(replace='password', replace_with='<AUTHORIZATION>'), ...}
Would you still accept a dict as a parameter and then convert it internally to the namedtuple? That would yield an easier API for me as a user.
Would you still accept a dict as a parameter and then convert it internally to the namedtuple? That would yield an easier API for me as a user.
Absolutely
I'm looking at writing a PR for this, but why would you use a namedtuple for this over a simple dict? The dict key is the value for replace_with.
When you pass in placeholders per cassette, you lose all default placeholders (https://github.com/sigmavirus24/betamax/blob/4126cf86b778ef3c5fe31386040e62f7ee9c1641/betamax/cassette/cassette.py#L42-L45). I'd like to pass in additional overrides for generated content, but this shouldn't be global.