From 34115477ab222bfe72558e74d9444e5734a56d4f Mon Sep 17 00:00:00 2001 From: shockrah Date: Thu, 6 May 2021 17:03:24 -0700 Subject: [PATCH] + Mostly adding quality of life changes in this patch with the mock client These changes will make it easier to read through verbose logs with some tactful colors (yellow) --- json-api/client-tests/config.py | 10 ++++++++++ json-api/client-tests/request.py | 19 ++++++++++--------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/json-api/client-tests/config.py b/json-api/client-tests/config.py index bb768c8..118556c 100644 --- a/json-api/client-tests/config.py +++ b/json-api/client-tests/config.py @@ -8,6 +8,15 @@ class Server: self.wsurl = meta.get('wsurl') self.serv_name = meta.get('name') + def __str__(self) -> str: + fields = { + 'url': self.url, + 'wsurl': self.wsurl, + 'name': self.serv_name + } + return str(fields) + + class Admin: def __init__(self, user: dict, server: dict): self.id = user.get('id') @@ -33,6 +42,7 @@ def create_admin() -> Admin : raw = json.loads(proc.stdout) user = raw.get('user') server = raw.get('server') + print(f'Raw data to use as user: {raw}') if user is None or server is None: return None else: diff --git a/json-api/client-tests/request.py b/json-api/client-tests/request.py index 45b3152..529aa0d 100644 --- a/json-api/client-tests/request.py +++ b/json-api/client-tests/request.py @@ -4,6 +4,7 @@ import requests NC = '\033[0m' RED = '\033[1;31m' GREEN = '\033[1;32m' +YELLOW = '\033[1;33m' class Request: @@ -56,23 +57,23 @@ class Request: print(abstract) print('\t', self.method, ' ', self.url) if len(self.headers) != 0: - print('\tRequest-Headers ', self.headers) + print(YELLOW + '\tRequest-Headers ' + NC, self.headers) if len(self.qs) != 0: - print('\tQuery-Dictionary ', self.qs) + print(YELLOW + '\tQuery-Dictionary' + NC, self.qs) if self.body is not None: - print('\tRequest-Body ', str(self.body)) + print(YELLOW + '\tRequest-Body' + NC, str(self.body)) if self.verbose: - print(f'\tResponse-Status {self.response.status_code}') - print(f'\tResponse-Headers {self.response.headers}') - print(f'\tResponse-Text {self.response.text}') + print(f'\t{YELLOW}Response-Status{NC} {self.response.status_code}') + print(f'\t{YELLOW}Response-Headers{NC} {self.response.headers}') + print(f'\t{YELLOW}Response-Text{NC} {self.response.text}') else: print(f'{GREEN}Pass{NC} {self.method} {self.url}') if self.verbose: - print(f'\tResponse-Status {self.response.status_code}') - print(f'\tResponse-Headers {self.response.headers}') - print(f'\tResponse-Text {self.response.text}') + print(f'\t{YELLOW}Response-Status{NC} {self.response.status_code}') + print(f'\t{YELLOW}Response-Headers{NC} {self.response.headers}') + print(f'\t{YELLOW}Response-Text{NC} {self.response.text}')