+ Adding first pass of a pair of invite endpoint tests

This commit is contained in:
shockrah 2021-04-26 02:01:04 -07:00
parent c9658ad5b4
commit 61a3f1d4f5

View File

@ -57,6 +57,22 @@ def req(admin: Admin, method: str, path: str, qs: dict, hope: int, headers: dict
return Request(url, method, params, headers, hope, body, verbose) return Request(url, method, params, headers, hope, body, verbose)
def make_and_receive_invite(admin: Admin) -> (Request, Request):
make_inv_req = req(admin, 'post', '/invite/create', {}, 200, verbose=True)
user_inv_req = req(admin , 'get' , '/invite/join', new_invite_body, 200, verbose=True)
# Fire the first request and do some safety checks in case the request fails
make_inv_req.fire()
if make_inv_req.response is None:
return (make_inv_req, user_inv_req)
# Setup to fire the second request, .fire() is safe to blindly use at this point
new_invite_body = make_inv_req.response.json()['invite']
user_inv_req.fire()
return (make_inv_req, user_inv_req)
if __name__ == '__main__': if __name__ == '__main__':
admin = create_admin() admin = create_admin()
if admin is None: if admin is None:
@ -79,6 +95,8 @@ if __name__ == '__main__':
mk_chan_sanity, chan_id = make_channel(admin.server.url, admin.id, admin.jwt) mk_chan_sanity, chan_id = make_channel(admin.server.url, admin.id, admin.jwt)
mk_chan_to_delete, del_chan_id = make_channel(admin.server.url, admin.id, admin.jwt) mk_chan_to_delete, del_chan_id = make_channel(admin.server.url, admin.id, admin.jwt)
# Invite test
# Container for most/all the generic requests we want to fire off # Container for most/all the generic requests we want to fire off
requests.extend([ requests.extend([
req(fake_user, 'get', '/channels/list', {}, 401), req(fake_user, 'get', '/channels/list', {}, 401),
@ -94,9 +112,12 @@ if __name__ == '__main__':
req(admin, 'get', '/members/me', {}, 200), req(admin, 'get', '/members/me', {}, 200),
req(admin, 'get', '/members/get_online', {}, 200), req(admin, 'get', '/members/get_online', {}, 200),
req(admin, 'post', '/members/me/nickname', {'nick': f'randy-{time()}'}, 200), req(admin, 'post', '/members/me/nickname', {'nick': f'randy-{time()}'}, 200),
req(admin , 'post', '/invite/create', {}, 200, verbose=True)
]) ])
# add this after fire the generic tests
inv_req_mk, inv_req_use = make_and_receive_invite(admin)
# Fire off
for req in requests: for req in requests:
req.fire() req.fire()
@ -104,6 +125,11 @@ if __name__ == '__main__':
requests.insert(0, login_req) requests.insert(0, login_req)
requests.insert(0, mk_chan_sanity) requests.insert(0, mk_chan_sanity)
requests.insert(0, mk_chan_to_delete) requests.insert(0, mk_chan_to_delete)
# Append the invite endpoint tests(only because they're meant to come near the end)
requests.append(inv_req_mk)
if inv_req_use is not None:
requests.append(inv_req_use)
pass_count = 0 pass_count = 0
for r in requests: for r in requests:
r.show_response() r.show_response()