Verified /message/send works as intended for now with new testing api
This commit is contained in:
parent
64eb2b072f
commit
cf7c5517bb
@ -67,6 +67,12 @@ class Worker:
|
|||||||
for key in ids:
|
for key in ids:
|
||||||
self.responses[key].log()
|
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):
|
def request(self, method: str, path: str, auth: str, opts: dict, expectation: int):
|
||||||
assert(path[0] == '/')
|
assert(path[0] == '/')
|
||||||
@ -91,7 +97,6 @@ def run(worker: Worker):
|
|||||||
TEXT_CHAN = 2
|
TEXT_CHAN = 2
|
||||||
# preliminary test
|
# preliminary test
|
||||||
req_login = worker.request('post', '/login', 'basic',{}, 200)
|
req_login = worker.request('post', '/login', 'basic',{}, 200)
|
||||||
print(worker.responses[req_login])
|
|
||||||
jwt = worker.responses[req_login].json()['jwt']
|
jwt = worker.responses[req_login].json()['jwt']
|
||||||
|
|
||||||
new_channel_name = time.time()
|
new_channel_name = time.time()
|
||||||
@ -107,9 +112,9 @@ def run(worker: Worker):
|
|||||||
{'init': ['post', '/channels/list', {}], 'auth': jwt, 'hope': 404},
|
{'init': ['post', '/channels/list', {}], 'auth': jwt, 'hope': 404},
|
||||||
|
|
||||||
# somehow save this garbino
|
# 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
|
# 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', {}], 'auth': jwt, 'hope': 400},
|
||||||
{'init': ['post', '/channels/create', {'name': 123, 'kind': 'adsf'}], '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)
|
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()
|
worker.logs()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
Reference in New Issue
Block a user