betamaxpy / betamax

A VCR imitation designed only for python-requests.
https://betamax.readthedocs.io/en/latest/
Other
567 stars 62 forks source link

test_replays_response_from_cassette fails because of X-Amzn-Trace-Id #184

Open FelixSchwarz opened 4 years ago

FelixSchwarz commented 4 years ago
$ pytest tests/integration/test_record_modes.py
.F......                                                                [100%]
================================== FAILURES ===================================
_____________ TestRecordOnce.test_replays_response_from_cassette ______________

            assert r0_headers == r1_headers
>           assert r0.content == r1.content
E           assert b'{\n  "args"...org/get"\n}\n' == b'{\n  "args"...org/get"\n}\n'
E             At index 208 diff: b'd' != b'e'
E             Full diff:
E               (
E                b'{\n  "args": {}, \n  "headers": {\n    "Accept": "*/*", \n    "Accept-Encodi'
E                b'ng": "gzip, deflate", \n    "Host": "httpbin.org", \n    "User-Agent": "py'
E             -  b'thon-requests/2.23.0", \n    "X-Amzn-Trace-Id": "Root=1-5e91e8b3-e94687be'
E             ?                                                                     ^^^^ ^^^...
E             
E             ...Full output truncated (9 lines hidden), use '-vv' to show

tests/integration/test_record_modes.py:43: AssertionError

The test code already removes some headers which may differ between requests but the difference shown above is in r1.content and I don't know what the best way is to ignore X-Amzn-Trace-Id there.

It seems as if httpbin.org uses Amazon's Elastic Load Balancing which adds a unique X-Amzn-Trace-Id header. That header is different for each request.

sigmavirus24 commented 4 years ago

This is because httpbin has moved hosting providers.

It makes sense to me for us to either:

Either way, contributions will be necessary for this as I'm not able to spend a significant amount of time on this.