Changeset View
Changeset View
Standalone View
Standalone View
docker/tests/conftest.py
Show First 20 Lines • Show All 119 Lines • ▼ Show 20 Lines | |||||
# Utility functions | # Utility functions | ||||
def apiget(path: str, verb: str = 'GET', **kwargs): | def apiget(path: str, verb: str = 'GET', **kwargs): | ||||
"""Query the API at path and return the json result or raise an | """Query the API at path and return the json result or raise an | ||||
AssertionError""" | AssertionError""" | ||||
url = urljoin(APIURL, path) | url = urljoin(APIURL, path) | ||||
resp = requests.request(verb, url, **kwargs) | resp = requests.request(verb, url, **kwargs) | ||||
assert resp.status_code == 200, f'failed to retrieve {url} ({resp})' | assert resp.status_code == 200, f'failed to retrieve {url}: {resp.text}' | ||||
return resp.json() | return resp.json() | ||||
def pollapi(path: str, verb: str = 'GET', **kwargs): | def pollapi(path: str, verb: str = 'GET', **kwargs): | ||||
"""Poll the API at path until it returns an OK result""" | """Poll the API at path until it returns an OK result""" | ||||
url = urljoin(APIURL, path) | url = urljoin(APIURL, path) | ||||
for i in range(60): | for i in range(60): | ||||
resp = requests.request(verb, url, **kwargs) | resp = requests.request(verb, url, **kwargs) | ||||
Show All 18 Lines |