forked from openedx/openedx-webhooks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshow_cassettes.py
executable file
·30 lines (26 loc) · 987 Bytes
/
show_cassettes.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env python
"""
Summarize the contents of Betamax cassettes::
$ ./show_cassettes.py tests/cassettes/*.json
"""
import glob
import json
import sys
for filename in sys.argv[1:]:
with open(filename) as cassette:
recorded_data = json.load(cassette)
print "{}:".format(filename)
interactions = recorded_data['http_interactions']
if interactions:
for interaction in interactions:
print " {}".format(interaction['request']['uri'])
status = interaction['response']['status']['code']
if status == 200:
for k, v in interaction['response']['body'].items():
if k in ['string', 'base64_string']:
v = "{} bytes".format(len(v))
print " {}: {}".format(k, v)
else:
print " *** {}".format(status)
else:
print " - None -"