Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import json
- import requests
- old_to_new = {}
- with open('requestlog-customer-charges.json') as requests_json:
- entries = json.load(requests_json)
- for entry in entries:
- old_res = entry['response']
- old_code = old_res['code']
- old_body = json.loads(old_res['body'])
- old_id = old_body['id']
- request = entry['request']
- url = 'https://api.stripe.com' + request['url']
- headers = request['headers']
- body: str = request['body']
- for key_id in old_to_new:
- url = url.replace(key_id, old_to_new[key_id])
- body = body.replace(key_id, old_to_new[key_id])
- method = request['method']
- res = requests.request(method, url, headers=headers, data=body)
- assert res.status_code == old_code
- new_body = res.json()
- new_id = new_body['id']
- old_to_new[old_id] = new_id
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement