mirror of
https://github.com/kevin1024/vcrpy.git
synced 2025-12-09 09:13:23 +00:00
update old cassette detection
This commit is contained in:
60
tests/fixtures/migration/new_cassette.json
vendored
60
tests/fixtures/migration/new_cassette.json
vendored
@@ -1,31 +1,35 @@
|
|||||||
[
|
{
|
||||||
{
|
"version": 1,
|
||||||
"request": {
|
"interactions":
|
||||||
"body": null,
|
[
|
||||||
"headers": {
|
{
|
||||||
"Accept": ["*/*"],
|
"request": {
|
||||||
"Accept-Encoding": ["gzip, deflate, compress"],
|
"body": null,
|
||||||
"User-Agent": ["python-requests/2.2.1 CPython/2.6.1 Darwin/10.8.0"]
|
"headers": {
|
||||||
|
"Accept": ["*/*"],
|
||||||
|
"Accept-Encoding": ["gzip, deflate, compress"],
|
||||||
|
"User-Agent": ["python-requests/2.2.1 CPython/2.6.1 Darwin/10.8.0"]
|
||||||
|
},
|
||||||
|
"method": "GET",
|
||||||
|
"uri": "http://httpbin.org/ip"
|
||||||
},
|
},
|
||||||
"method": "GET",
|
"response": {
|
||||||
"uri": "http://httpbin.org/ip"
|
"status": {
|
||||||
},
|
"message": "OK",
|
||||||
"response": {
|
"code": 200
|
||||||
"status": {
|
},
|
||||||
"message": "OK",
|
"headers": {
|
||||||
"code": 200
|
"access-control-allow-origin": ["*"],
|
||||||
},
|
"content-type": ["application/json"],
|
||||||
"headers": {
|
"date": ["Mon, 21 Apr 2014 23:13:40 GMT"],
|
||||||
"access-control-allow-origin": ["*"],
|
"server": ["gunicorn/0.17.4"],
|
||||||
"content-type": ["application/json"],
|
"content-length": ["32"],
|
||||||
"date": ["Mon, 21 Apr 2014 23:13:40 GMT"],
|
"connection": ["keep-alive"]
|
||||||
"server": ["gunicorn/0.17.4"],
|
},
|
||||||
"content-length": ["32"],
|
"body": {
|
||||||
"connection": ["keep-alive"]
|
"string": "{\n \"origin\": \"217.122.164.194\"\n}"
|
||||||
},
|
}
|
||||||
"body": {
|
|
||||||
"string": "{\n \"origin\": \"217.122.164.194\"\n}"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
]
|
||||||
]
|
}
|
||||||
|
|||||||
2
tests/fixtures/migration/new_cassette.yaml
vendored
2
tests/fixtures/migration/new_cassette.yaml
vendored
@@ -1,3 +1,5 @@
|
|||||||
|
version: 1
|
||||||
|
interactions:
|
||||||
- request:
|
- request:
|
||||||
body: null
|
body: null
|
||||||
headers:
|
headers:
|
||||||
|
|||||||
@@ -19,6 +19,13 @@ Deserializing: string (yaml converts from utf-8) -> bytestring
|
|||||||
|
|
||||||
def deserialize(cassette_string, serializer):
|
def deserialize(cassette_string, serializer):
|
||||||
data = serializer.deserialize(cassette_string)
|
data = serializer.deserialize(cassette_string)
|
||||||
|
if not isinstance(data, dict):
|
||||||
|
raise ValueError(
|
||||||
|
"Your cassette files were generated in an older version "
|
||||||
|
"of VCR. Delete your cassettes or run the migration script."
|
||||||
|
"See http://git.io/mHhLBg for more details."
|
||||||
|
)
|
||||||
|
|
||||||
requests = [Request._from_dict(r['request']) for r in data['interactions']]
|
requests = [Request._from_dict(r['request']) for r in data['interactions']]
|
||||||
responses = [compat.convert_to_bytes(r['response']) for r in data['interactions']]
|
responses = [compat.convert_to_bytes(r['response']) for r in data['interactions']]
|
||||||
return requests, responses
|
return requests, responses
|
||||||
|
|||||||
Reference in New Issue
Block a user