Client tester now uses channel_id where applicable for api parameters
as well as being less explicit about what it passes to the query string
This commit is contained in:
parent
2d6739438a
commit
21b184b324
@ -52,16 +52,14 @@ class Worker:
|
|||||||
@auth: Denotes if we use basic auth or jwt if its not 'basic'
|
@auth: Denotes if we use basic auth or jwt if its not 'basic'
|
||||||
|
|
||||||
'''
|
'''
|
||||||
if type(auth) == str:
|
# id is basically always required by the api so we mindlessly add it here
|
||||||
opts['id'] = self.id
|
opts['id'] = self.id
|
||||||
|
|
||||||
if auth == 'basic':
|
if auth == 'basic':
|
||||||
opts['secret'] = self.secret
|
opts['secret'] = self.secret
|
||||||
else:
|
else:
|
||||||
opts['jwt'] = auth
|
opts['jwt'] = auth
|
||||||
return opts
|
return opts
|
||||||
else:
|
|
||||||
# if its not a string we don't add anything in
|
|
||||||
return opts
|
|
||||||
|
|
||||||
def logs(self):
|
def logs(self):
|
||||||
ids = sorted(self.requests.keys()) # shared keys in requests/responses
|
ids = sorted(self.requests.keys()) # shared keys in requests/responses
|
||||||
@ -71,8 +69,8 @@ class Worker:
|
|||||||
# Logg the provided data to ensure that _it_ wasn't the cause for error
|
# Logg the provided data to ensure that _it_ wasn't the cause for error
|
||||||
resp = self.responses[key]
|
resp = self.responses[key]
|
||||||
if resp.code != resp.expected:
|
if resp.code != resp.expected:
|
||||||
opts = self.requests[key].params
|
self.responses[key].log()
|
||||||
print(f'\tParams: {opts}')
|
# if body is request to be shown then dump it tabbed out by 1 tab
|
||||||
if self.body_logs[key] is True:
|
if self.body_logs[key] is True:
|
||||||
print(f'\tBody: {self.responses[key].body}')
|
print(f'\tBody: {self.responses[key].body}')
|
||||||
|
|
||||||
@ -111,7 +109,6 @@ def run(worker: Worker):
|
|||||||
channel_tests = [
|
channel_tests = [
|
||||||
# sanity check
|
# sanity check
|
||||||
{'init': ['get', '/channels/list', {}], 'auth': None, 'hope': 401},
|
{'init': ['get', '/channels/list', {}], 'auth': None, 'hope': 401},
|
||||||
|
|
||||||
{'init': ['post', '/channels/list', {}], 'auth': jwt, 'hope': 404},
|
{'init': ['post', '/channels/list', {}], 'auth': jwt, 'hope': 404},
|
||||||
|
|
||||||
{'init': ['post', '/channels/create', {'name': str(new_channel_name), 'kind': TEXT_CHAN, 'description': 'asdf'}], 'auth': jwt, 'hope': 200},
|
{'init': ['post', '/channels/create', {'name': str(new_channel_name), 'kind': TEXT_CHAN, 'description': 'asdf'}], 'auth': jwt, 'hope': 200},
|
||||||
@ -142,46 +139,46 @@ def run(worker: Worker):
|
|||||||
|
|
||||||
message_tests = [
|
message_tests = [
|
||||||
# bs message spam
|
# bs message spam
|
||||||
{'init': ['post', '/message/send', {'channel': chan_d['id'], 'content': 'bs content'}], 'auth': jwt, 'hope': 200},
|
{'init': ['post', '/message/send', {'channel_id': chan_d['id'], 'content': 'bs content'}], 'auth': jwt, 'hope': 200},
|
||||||
{'init': ['post', '/message/send', {'channel': chan_d['id'], 'content': 'bs content'}], 'auth': jwt, 'hope': 200},
|
{'init': ['post', '/message/send', {'channel_id': chan_d['id'], 'content': 'bs content'}], 'auth': jwt, 'hope': 200},
|
||||||
{'init': ['post', '/message/send', {'channel': chan_d['id'], 'content': 'bs content'}], 'auth': jwt, 'hope': 200},
|
{'init': ['post', '/message/send', {'channel_id': chan_d['id'], 'content': 'bs content'}], 'auth': jwt, 'hope': 200},
|
||||||
{'init': ['post', '/message/send', {'channel': chan_d['id'], 'content': 'bs content'}], 'auth': jwt, 'hope': 200},
|
{'init': ['post', '/message/send', {'channel_id': chan_d['id'], 'content': 'bs content'}], 'auth': jwt, 'hope': 200},
|
||||||
|
|
||||||
# can we get them back tho?
|
# can we get them back tho?
|
||||||
{
|
{
|
||||||
'init': [
|
'init': [
|
||||||
'get', '/message/get_range', {'channel': 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
|
'auth': jwt, 'hope': 200
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'init': [
|
'init': [
|
||||||
'get', '/message/get_range', {'channel': 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
|
'auth': jwt, 'hope': 400
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'init': [
|
'init': [
|
||||||
'get', '/message/get_range', {'channel': 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
|
'auth': jwt, 'hope': 400
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'init': [
|
'init': [
|
||||||
'get', '/message/get_range', {'channel': 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
|
'auth': jwt, 'hope': 400
|
||||||
},
|
},
|
||||||
# two tests that follow the rules
|
# two tests that follow the rules
|
||||||
{
|
{
|
||||||
'init': [
|
'init': [
|
||||||
'get', '/message/from_id', {'start': 1, 'channel': 3}
|
'get', '/message/from_id', {'start': 1, 'channel_id': 3}
|
||||||
],
|
],
|
||||||
'auth': jwt, 'hope': 200, 'body': True
|
'auth': jwt, 'hope': 200, 'body': True
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'init': [
|
'init': [
|
||||||
'get', '/message/from_id', {'start':1, 'channel':3, 'limit':2}
|
'get', '/message/from_id', {'start':1, 'channel_id':3, 'limit':2}
|
||||||
],
|
],
|
||||||
'auth': jwt, 'hope': 200, 'body': True
|
'auth': jwt, 'hope': 200, 'body': True
|
||||||
},
|
},
|
||||||
@ -189,14 +186,14 @@ def run(worker: Worker):
|
|||||||
{
|
{
|
||||||
# channel doesn't exist so a 404 seems to be inorder
|
# channel doesn't exist so a 404 seems to be inorder
|
||||||
'init': [
|
'init': [
|
||||||
'get', '/message/from_id', {'start': 1, 'channel':9}
|
'get', '/message/from_id', {'start': 1, 'channel_id':9}
|
||||||
],
|
],
|
||||||
'auth': jwt, 'hope': 404
|
'auth': jwt, 'hope': 404
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'init': [
|
'init': [
|
||||||
# good channel but id is tooo high
|
# good channel but id is tooo high
|
||||||
'get', '/message/from_id', {'start': 5, 'channel':3}
|
'get', '/message/from_id', {'start': 5, 'channel_id':3}
|
||||||
],
|
],
|
||||||
'auth': jwt, 'hope': 404
|
'auth': jwt, 'hope': 404
|
||||||
},
|
},
|
||||||
@ -216,5 +213,5 @@ def run(worker: Worker):
|
|||||||
worker.logs()
|
worker.logs()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
worker = Worker('http://localhost:8888', create_admin=True)
|
worker = Worker('http://localhost:4536', create_admin=True)
|
||||||
run(worker)
|
run(worker)
|
||||||
|
Loading…
Reference in New Issue
Block a user