diff options
Diffstat (limited to 'subplot.py')
-rw-r--r-- | subplot.py | 28 |
1 files changed, 23 insertions, 5 deletions
@@ -1,18 +1,36 @@ +import logging +import requests +import urllib3 + +urllib3.disable_warnings() + + def nop(ctx): - pass + ctx["base"] = "https://web" def get(ctx, path=None): - pass + r = requests.get(f"{ctx['base']}{path}", verify=False) + ctx["http.status"] = r.status_code + ctx["http.headers"] = dict(r.headers) + ctx["http.body"] = r.text + logging.debug(f"status: {r.status_code}") + logging.debug(f"headers: {r.headers}") + logging.debug(f"body: {r.text}") def status_code(ctx, code=None): - pass + assert int(ctx["http.status"]) == int(code) def has_header(ctx, header=None, value=None): - pass + logging.debug(f"wanted header: {header!r}") + logging.debug(f"wanted value: {value}") + assert header in ctx["http.headers"] + assert ctx["http.headers"][header] == value def body_matches_file(ctx, filename=None): - pass + with open(filename) as f: + data = f.read() + assert data == ctx["http.body"] |