diff --git a/server-api/client-tests/web/http.py b/server-api/client-tests/web/http.py index aec896b..0e2a523 100644 --- a/server-api/client-tests/web/http.py +++ b/server-api/client-tests/web/http.py @@ -1,6 +1,7 @@ import sys import requests import time +import json class RequestError(Exception): pass @@ -46,6 +47,17 @@ class Response: print(msg, file=self.out) + def json(self): + ''' + Force an interpretation of json from the body + NOTE: this method is rather obtuse and a massive afterthough so its usage + should be limited as much as possible + ''' + try: + return json.loads(self.body) + except: + return {} + def __str__(self): ''' Returns: str(Response) -> `code => response.bdoy` @@ -79,7 +91,7 @@ class Request: raise RequestError('Invalid method passed') - def make(self, hope: int) -> Response: + def make(self, hope: int, auth: str) -> Response: ''' @param hope: int -> status code we hope to get back @return Response -> Wrapper around server http response