updating tests for members routes

This commit is contained in:
shockrah
2021-02-20 20:14:10 -08:00
parent c4db03f962
commit 34736bef3f
3 changed files with 36 additions and 9 deletions

View File

@@ -102,6 +102,7 @@ def run(worker: Worker):
# 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)
print(worker.responses[req_login].json())
jwt = worker.responses[req_login].json()['jwt']
new_channel_name = time.time()
@@ -147,25 +148,25 @@ def run(worker: Worker):
# can we get them back tho?
{
'init': [
'get', '/message/get_range', {'channel_id': chan_d['id'], 'start-time': int(msg_chan_name-10), 'end-time': int(msg_chan_name + 10)}
'get', '/message/get_range', {'channel_id': chan_d['id'], 'start_time': int(msg_chan_name-10), 'end_time': int(msg_chan_name + 10)}
],
'auth': jwt, 'hope': 200
},
{
'init': [
'get', '/message/get_range', {'channel_id': chan_d['id'], 'end-time': int(msg_chan_name)}
'get', '/message/get_range', {'channel_id': chan_d['id'], 'end_time': int(msg_chan_name)}
],
'auth': jwt, 'hope': 400
},
{
'init': [
'get', '/message/get_range', {'channel_id': chan_d['id'], 'start-time': int(msg_chan_name), 'end-time': int(msg_chan_name)}
'get', '/message/get_range', {'channel_id': chan_d['id'], 'start_time': int(msg_chan_name), 'end_time': int(msg_chan_name)}
],
'auth': jwt, 'hope': 400
},
{
'init': [
'get', '/message/get_range', {'channel_id': chan_d['id'], 'end-time': int(msg_chan_name), 'start-time': int(msg_chan_name)}
'get', '/message/get_range', {'channel_id': chan_d['id'], 'end_time': int(msg_chan_name), 'start_time': int(msg_chan_name)}
],
'auth': jwt, 'hope': 400
},
@@ -210,8 +211,23 @@ def run(worker: Worker):
member_tests = [
{ 'init': ['get', '/members/me', {}], 'auth': jwt, 'hope': 200 },
{ 'init': ['get', '/members/me', {'asdf': 123}], 'auth': jwt, 'hope': 200 },
{ 'init': ['get', '/members/get_online', {}], 'auth': jwt, 'hope': 200, 'body': True},
]
for test in member_tests:
method, path, opts = test['init']
auth = test['auth']
hope = test['hope']
if 'body' in test:
worker.request(method, path, auth, opts, hope, show_body=test['body'])
else:
worker.request(method, path, auth, opts, hope)
worker.logs()
if __name__ == '__main__':
worker = Worker('https://localhost', create_admin=True)
worker = Worker('http://localhost:4536', create_admin=True)
run(worker)

View File

@@ -90,7 +90,7 @@ class Response:
# no color on the query like ever(because its typically massive
if show_query:
msg += f'\n\t{self.query_string[:80]}'
msg += f'\n\t{self.query_string[:77]}...'
self.__write_msg(msg)