+Adding support for more verbose loggin
More tests which currently are failing with /message/time_range
This commit is contained in:
parent
cf7c5517bb
commit
33916868da
@ -16,6 +16,7 @@ class Worker:
|
|||||||
self.domain = domain
|
self.domain = domain
|
||||||
self.requests = {}
|
self.requests = {}
|
||||||
self.responses = {}
|
self.responses = {}
|
||||||
|
self.body_logs = {}
|
||||||
|
|
||||||
self.jwt = None # never gets assigned until /login is hit
|
self.jwt = None # never gets assigned until /login is hit
|
||||||
self.basic_creds = self.__create_admin()
|
self.basic_creds = self.__create_admin()
|
||||||
@ -72,9 +73,11 @@ class Worker:
|
|||||||
if resp.code != resp.expected:
|
if resp.code != resp.expected:
|
||||||
opts = self.requests[key].params
|
opts = self.requests[key].params
|
||||||
print(f'\tParams: {opts}')
|
print(f'\tParams: {opts}')
|
||||||
|
if self.body_logs[key] is True:
|
||||||
|
print(f'\tBody: {self.responses[key].body}')
|
||||||
|
|
||||||
|
|
||||||
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, show_body=False):
|
||||||
assert(path[0] == '/')
|
assert(path[0] == '/')
|
||||||
|
|
||||||
# First make sure we add in the correct auth params that are requested
|
# First make sure we add in the correct auth params that are requested
|
||||||
@ -84,10 +87,13 @@ class Worker:
|
|||||||
url = self.domain + path
|
url = self.domain + path
|
||||||
req = http.Request(method, url, opts)
|
req = http.Request(method, url, opts)
|
||||||
r_id = time.time()
|
r_id = time.time()
|
||||||
self.requests[r_id] = req
|
|
||||||
|
|
||||||
resp = req.make(expectation)
|
resp = req.make(expectation)
|
||||||
|
|
||||||
|
# update log trackers
|
||||||
|
self.requests[r_id] = req
|
||||||
self.responses[r_id] = resp
|
self.responses[r_id] = resp
|
||||||
|
self.body_logs[r_id] = show_body
|
||||||
|
|
||||||
return r_id
|
return r_id
|
||||||
|
|
||||||
@ -138,13 +144,30 @@ def run(worker: Worker):
|
|||||||
}, 200)
|
}, 200)
|
||||||
chan_d = worker.responses[_id].json()
|
chan_d = worker.responses[_id].json()
|
||||||
|
|
||||||
# spam some messages
|
message_tests = [
|
||||||
for i in range(5):
|
# bs message spam
|
||||||
msg = f'Message id: {i}'
|
{'init': ['post', '/message/send', {'channel': chan_d['id'], 'content': 'bs content'}], 'auth': jwt, 'hope': 200},
|
||||||
worker.request('post', '/message/send', jwt, {
|
{'init': ['post', '/message/send', {'channel': chan_d['id'], 'content': 'bs content'}], 'auth': jwt, 'hope': 200},
|
||||||
'channel': chan_d['id'],
|
{'init': ['post', '/message/send', {'channel': chan_d['id'], 'content': 'bs content'}], 'auth': jwt, 'hope': 200},
|
||||||
'content': msg
|
{'init': ['post', '/message/send', {'channel': chan_d['id'], 'content': 'bs content'}], 'auth': jwt, 'hope': 200},
|
||||||
}, 200)
|
|
||||||
|
# can we get them back tho?
|
||||||
|
{'init': ['get', '/message/get_range', {'channel': chan_d['id'], 'start-time': int(msg_chan_name)-10, 'end-time': int(msg_chan_name)}], 'auth': jwt, 'hope': 200, 'body': True},
|
||||||
|
{'init': ['get', '/message/get_range', {'channel': chan_d['id'], 'end-time': int(msg_chan_name)}], 'auth': jwt, 'hope': 400},
|
||||||
|
{'init': ['get', '/message/get_range', {'channel': 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': chan_d['id'], 'end-time': int(msg_chan_name), 'start-time': int(msg_chan_name)}], 'auth': jwt, 'hope': 400},
|
||||||
|
]
|
||||||
|
|
||||||
|
for test in message_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()
|
worker.logs()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user