1Metadata-Version: 1.1 2Name: betamax 3Version: 0.8.1 4Summary: A VCR imitation for python-requests 5Home-page: https://github.com/sigmavirus24/betamax 6Author: Ian Stapleton Cordasco 7Author-email: graffatcolmingov@gmail.com 8License: Apache 2.0 9Description-Content-Type: UNKNOWN 10Description: betamax 11 ======= 12 13 Betamax is a VCR_ imitation for requests. This will make mocking out requests 14 much easier. It is tested on `Travis CI`_. 15 16 Put in a more humorous way: "Betamax records your HTTP interactions so the NSA 17 does not have to." 18 19 Example Use 20 ----------- 21 22 .. code-block:: python 23 24 from betamax import Betamax 25 from requests import Session 26 from unittest import TestCase 27 28 with Betamax.configure() as config: 29 config.cassette_library_dir = 'tests/fixtures/cassettes' 30 31 32 class TestGitHubAPI(TestCase): 33 def setUp(self): 34 self.session = Session() 35 self.headers.update(...) 36 37 # Set the cassette in a line other than the context declaration 38 def test_user(self): 39 with Betamax(self.session) as vcr: 40 vcr.use_cassette('user') 41 resp = self.session.get('https://api.github.com/user', 42 auth=('user', 'pass')) 43 assert resp.json()['login'] is not None 44 45 # Set the cassette in line with the context declaration 46 def test_repo(self): 47 with Betamax(self.session).use_cassette('repo'): 48 resp = self.session.get( 49 'https://api.github.com/repos/sigmavirus24/github3.py' 50 ) 51 assert resp.json()['owner'] != {} 52 53 What does it even do? 54 --------------------- 55 56 If you are unfamiliar with VCR_, you might need a better explanation of what 57 Betamax does. 58 59 Betamax intercepts every request you make and attempts to find a matching 60 request that has already been intercepted and recorded. Two things can then 61 happen: 62 63 1. If there is a matching request, it will return the response that is 64 associated with it. 65 2. If there is **not** a matching request and it is allowed to record new 66 responses, it will make the request, record the response and return the 67 response. 68 69 Recorded requests and corresponding responses - also known as interactions - 70 are stored in files called cassettes. (An example cassette can be seen in 71 the `examples section of the documentation`_.) The directory you store your 72 cassettes in is called your library, or your `cassette library`_. 73 74 VCR Cassette Compatibility 75 -------------------------- 76 77 Betamax can use any VCR-recorded cassette as of this point in time. The only 78 caveat is that python-requests returns a URL on each response. VCR does not 79 store that in a cassette now but we will. Any VCR-recorded cassette used to 80 playback a response will unfortunately not have a URL attribute on responses 81 that are returned. This is a minor annoyance but not something that can be 82 fixed. 83 84 Contributing 85 ------------ 86 87 You can check out the project board on waffle.io_ to see what the status of 88 each issue is. 89 90 .. _VCR: https://github.com/vcr/vcr 91 .. _Travis CI: https://travis-ci.org/sigmavirus24/betamax 92 .. _waffle.io: https://waffle.io/sigmavirus24/betamax 93 .. _examples section of the documentation: 94 http://betamax.readthedocs.org/en/latest/api.html#examples 95 .. _cassette library: 96 http://betamax.readthedocs.org/en/latest/cassettes.html 97 98 99 History 100 ======= 101 102 0.8.1 - 2018-03-13 103 ------------------ 104 105 - Previous attempts to sanitize cassette names were incomplete. 106 Sanitization has become more thorough which could have some affects on 107 existing cassette files. **This may cause new cassettes to be generated.** 108 109 - Fix bug where there may be an exception raised in a 110 ``betamax.exceptions.BetamaxError`` repr. 111 112 0.8.0 - 2016-08-16 113 ------------------ 114 115 - Add ``betamax_parametrized_recorder`` and ``betamax_parametrized_session`` 116 to our list of pytest fixtures so that users will have parametrized cassette 117 names when writing parametrized tests with our fixtures. (I wonder if I can 118 mention parametrization a bunch more times so I can say parametrize a lot in 119 this bullet note.) 120 - Add ``ValidationError`` and a set of subclasses for each possible validation 121 error. 122 - Raise ``InvalidOption`` on unknown cassette options rather than silently 123 ignoring extra options. 124 - Raise a subclass of ``ValidationError`` when a particular cassette option is 125 invalid, rather than silently ignoring the validation failure. 126 127 0.7.2 - 2016-08-04 128 ------------------ 129 130 - Fix bug with query string matcher where query-strings without values (e.g., 131 ``?foo&bar`` as opposed to ``?foo=1&bar=2``) were treated as if there were 132 no query string. 133 134 0.7.1 - 2016-06-14 135 ------------------ 136 137 - Fix issue #108 by effectively copying the items in the match_requests_on 138 list into the match_options set on a Cassette instance 139 140 0.7.0 - 2016-04-29 141 ------------------ 142 143 - Add ``before_record`` and ``before_playback`` hooks 144 145 - Allow per-cassette placeholders to be merged and override global 146 placeholders 147 148 - Fix bug where the ``QueryMatcher`` failed matching on high Unicode points 149 150 0.6.0 - 2016-04-12 151 ------------------ 152 153 - Add ``betamax_recorder`` pytest fixture 154 155 - Change default behaviour to allow duplicate interactions to be recorded in 156 single cassette 157 158 - Add ``allow_playback_repeats`` to allow an interaction to be used more than 159 once from a single cassette 160 161 - Always return a new ``Response`` object from an Interaction to allow for a 162 streaming response to be usable multiple times 163 164 - Remove CI support for Pythons 2.6 and 3.2 165 166 0.5.1 - 2015-10-24 167 ------------------ 168 169 - Fix bugs with requests 2.8.x integration 170 171 - Fix bugs with older versions of requests that were missing an HTTPHeaderDict 172 implementation 173 174 0.5.0 - 2015-07-15 175 ------------------ 176 177 - Add unittest integration in ``betamax.fixtures.unittest`` 178 179 - Add pytest integration in ``betamax.fixtures.pytest`` 180 181 - Add a decorator as a short cut for ``use_cassette`` 182 183 - Fix bug where body bytes were not always encoded on Python 3.2+ 184 185 Fixed by @bboe 186 187 0.4.2 - 2015-04-18 188 ------------------ 189 190 - Fix issue #58 reported by @bboe 191 192 Multiple cookies were not being properly stored or replayed after being 193 recorded. 194 195 - @leighlondon converted ``__all__`` to a tuple 196 197 0.4.1 - 2014-09-24 198 ------------------ 199 200 - Fix issue #39 reported by @buttscicles 201 202 This bug did not properly parse the Set-Cookie header with multiple cookies 203 when replaying a recorded response. 204 205 0.4.0 - 2014-07-29 206 ------------------ 207 208 - Allow the user to pass placeholders to ``Betamax#use_cassette``. 209 210 - Include Betamax's version number in cassettes 211 212 0.3.2 - 2014-06-05 213 ------------------ 214 215 - Fix request and response bodies courtesy of @dgouldin 216 217 0.3.1 - 2014-05-28 218 ------------------ 219 220 - Fix GitHub Issue #35 - Placeholders were not being properly applied to 221 request bodies. This release fixes that so placeholders are now behave as 222 expected with recorded request bodies. 223 224 0.3.0 - 2014-05-23 225 ------------------ 226 227 - Add ``Betamax#start`` and ``Betamax#stop`` to allow users to start recording 228 and stop without using a context-manager. 229 230 - Add ``digest-auth`` matcher to help users match the right request when using 231 requests' ``HTTPDigestAuth``. 232 233 - Reorganize and refactor the cassettes, matchers, and serializers modules. 234 235 - Refactor some portions of code a bit. 236 237 - ``Cassette.cassette_name`` no longer is the relative path to the file in 238 which the cassette is saved. To access that information use 239 ``Cassette.cassette_path``. The ``cassette_name`` attribute is now the name 240 that you pass to ``Betamax#use_cassette``. 241 242 0.2.0 - 2014-04-12 243 ------------------ 244 245 - Fix bug where new interactions recorded under ``new_episodes`` or ``all`` 246 were not actually saved to disk. 247 248 - Match URIs in a far more intelligent way. 249 250 - Use the Session's original adapters when making new requests 251 252 In the event the Session has a custom adapter mounted, e.g., the SSLAdapter 253 in requests-toolbelt, then we should probably use that. 254 255 - Add ``on_init`` hook to ``BaseMatcher`` so matcher authors can customize 256 initialization 257 258 - Add support for custom Serialization formats. See the docs for more info. 259 260 - Add support for preserving exact body bytes. 261 262 - Deprecate ``serialize`` keyword to ``Betamax#use_cassette`` in preference 263 for ``serialize_with`` (to be more similar to VCR). 264 265 0.1.6 - 2013-12-07 266 ------------------ 267 268 - Fix how global settings and per-invocation options are persisted and 269 honored. (#10) 270 271 - Support ``match_requests_on`` as a parameter sent to 272 ``Betamax#use_cassette``. (No issue) 273 274 0.1.5 - 2013-09-27 275 ------------------ 276 277 - Make sure what we pass to ``base64.b64decode`` is a bytes object 278 279 0.1.4 - 2013-09-27 280 ------------------ 281 282 - Do not try to sanitize something that may not exist. 283 284 0.1.3 - 2013-09-27 285 ------------------ 286 287 - Fix issue when response has a Content-Encoding of gzip and we need to 288 preserve the original bytes of the message. 289 290 0.1.2 - 2013-09-21 291 ------------------ 292 293 - Fix issues with how requests parses cookies out of responses 294 295 - Fix unicode issues with ``Response#text`` (trying to use ``Response#json`` 296 raises exception because it cannot use string decoding on a unicode string) 297 298 0.1.1 - 2013-09-19 299 ------------------ 300 301 - Fix issue where there is a unicode character not in ``range(128)`` 302 303 0.1.0 - 2013-09-17 304 ------------------ 305 306 - Initial Release 307 308 - Support for VCR generated cassettes (JSON only) 309 310 - Support for ``re_record_interval`` 311 312 - Support for the ``once``, ``all``, ``new_episodes``, ``all`` cassette modes 313 314 - Support for filtering sensitive data 315 316 - Support for the following methods of request matching: 317 318 - Method 319 320 - URI 321 322 - Host 323 324 - Path 325 326 - Query String 327 328 - Body 329 330 - Headers 331 332Platform: UNKNOWN 333Classifier: Development Status :: 4 - Beta 334Classifier: License :: OSI Approved 335Classifier: Intended Audience :: Developers 336Classifier: Programming Language :: Python 337Classifier: Programming Language :: Python :: 2 338Classifier: Programming Language :: Python :: 2.7 339Classifier: Programming Language :: Python :: 3 340Classifier: Programming Language :: Python :: 3.3 341Classifier: Programming Language :: Python :: 3.4 342Classifier: Programming Language :: Python :: 3.5 343Classifier: Programming Language :: Python :: Implementation :: CPython 344