diff --git a/server-api/client-tests/client.py b/server-api/client-tests/client.py index 66c19fe..f4ab45f 100644 --- a/server-api/client-tests/client.py +++ b/server-api/client-tests/client.py @@ -67,6 +67,12 @@ class Worker: for key in ids: self.responses[key].log() + # Logg the provided data to ensure that _it_ wasn't the cause for error + resp = self.responses[key] + if resp.code != resp.expected: + opts = self.requests[key].params + print(f'\tParams: {opts}') + def request(self, method: str, path: str, auth: str, opts: dict, expectation: int): assert(path[0] == '/') @@ -91,7 +97,6 @@ def run(worker: Worker): TEXT_CHAN = 2 # preliminary test req_login = worker.request('post', '/login', 'basic',{}, 200) - print(worker.responses[req_login]) jwt = worker.responses[req_login].json()['jwt'] new_channel_name = time.time() @@ -107,9 +112,9 @@ def run(worker: Worker): {'init': ['post', '/channels/list', {}], 'auth': jwt, 'hope': 404}, # somehow save this garbino - {'init': ['post', '/channels/create', {'name': str(new_channel_name), 'kind': 2, 'description': 'asdf'}], 'auth': jwt, 'hope': 200}, + {'init': ['post', '/channels/create', {'name': str(new_channel_name), 'kind': TEXT_CHAN, 'description': 'asdf'}], 'auth': jwt, 'hope': 200}, # Just a regular test no saving for this one - {'init': ['post', '/channels/create', {'name': str(new_channel_name+1), 'kind': 2,}], 'auth': jwt, 'hope': 200}, + {'init': ['post', '/channels/create', {'name': str(new_channel_name+1), 'kind': TEXT_CHAN,}], 'auth': jwt, 'hope': 200}, {'init': ['post', '/channels/create', {}], 'auth': jwt, 'hope': 400}, {'init': ['post', '/channels/create', {'name': 123, 'kind': 'adsf'}], 'auth': jwt, 'hope': 400}, @@ -126,6 +131,21 @@ def run(worker: Worker): worker.request(method, path, auth, opts, hope) + msg_chan_name = time.time() + _id = worker.request('post', '/channels/create', jwt, { + 'name': str(msg_chan_name), + 'kind': TEXT_CHAN, + }, 200) + chan_d = worker.responses[_id].json() + + # spam some messages + for i in range(5): + msg = f'Message id: {i}' + worker.request('post', '/message/send', jwt, { + 'channel': chan_d['id'], + 'content': msg + }, 200) + worker.logs() if __name__ == '__main__':