From d55a8420acfbd2929dbf6fceef87387e41cbb7cd Mon Sep 17 00:00:00 2001 From: shockrah Date: Sat, 23 Jan 2021 14:23:47 -0800 Subject: [PATCH] Testing from_id: good and bad cases here --- server-api/client-tests/client.py | 36 +++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/server-api/client-tests/client.py b/server-api/client-tests/client.py index 1b52c2e..bb09803 100644 --- a/server-api/client-tests/client.py +++ b/server-api/client-tests/client.py @@ -101,23 +101,19 @@ class Worker: def run(worker: Worker): VOICE_CHAN = 1 TEXT_CHAN = 2 - # preliminary test + # Basically every test requires a jwt to be passed in so we grab that here + # Should this fail so should nearly every other test from this point req_login = worker.request('post', '/login', 'basic',{}, 200) jwt = worker.responses[req_login].json()['jwt'] new_channel_name = time.time() channel_tests = [ - # init field provides args for Response object generation - # hop field gives us the ideal statuscode we want when we actually send the request - # NOTE: Grouping by status code - # sanity check {'init': ['get', '/channels/list', {}], 'auth': None, 'hope': 401}, {'init': ['post', '/channels/list', {}], 'auth': jwt, 'hope': 404}, - # somehow save this garbino {'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': TEXT_CHAN,}], 'auth': jwt, 'hope': 200}, @@ -176,6 +172,34 @@ def run(worker: Worker): ], 'auth': jwt, 'hope': 400 }, + # two tests that follow the rules + { + 'init': [ + 'get', '/message/from_id', {'start': 1, 'channel': 3} + ], + 'auth': jwt, 'hope': 200, 'body': True + }, + { + 'init': [ + 'get', '/message/from_id', {'start':1, 'channel':3, 'limit':2} + ], + 'auth': jwt, 'hope': 200, 'body': True + }, + # tests that don't follow the api's rules + { + # channel doesn't exist so a 404 seems to be inorder + 'init': [ + 'get', '/message/from_id', {'start': 1, 'channel':9} + ], + 'auth': jwt, 'hope': 404 + }, + { + 'init': [ + # good channel but id is tooo high + 'get', '/message/from_id', {'start': 5, 'channel':3} + ], + 'auth': jwt, 'hope': 404 + }, ] for test in message_tests: