Testing from_id: good and bad cases here
This commit is contained in:
parent
0e93b12cbd
commit
d55a8420ac
@ -101,23 +101,19 @@ class Worker:
|
|||||||
def run(worker: Worker):
|
def run(worker: Worker):
|
||||||
VOICE_CHAN = 1
|
VOICE_CHAN = 1
|
||||||
TEXT_CHAN = 2
|
TEXT_CHAN = 2
|
||||||
# preliminary test
|
# 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)
|
req_login = worker.request('post', '/login', 'basic',{}, 200)
|
||||||
jwt = worker.responses[req_login].json()['jwt']
|
jwt = worker.responses[req_login].json()['jwt']
|
||||||
|
|
||||||
new_channel_name = time.time()
|
new_channel_name = time.time()
|
||||||
|
|
||||||
channel_tests = [
|
channel_tests = [
|
||||||
# init field provides args for Response object generation
|
|
||||||
# hop field gives us the ideal statuscode we want when we actually send the request
|
|
||||||
# NOTE: Grouping by status code
|
|
||||||
|
|
||||||
# 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},
|
||||||
|
|
||||||
# somehow save this garbino
|
|
||||||
{'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},
|
||||||
# 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': TEXT_CHAN,}], 'auth': jwt, 'hope': 200},
|
{'init': ['post', '/channels/create', {'name': str(new_channel_name+1), 'kind': TEXT_CHAN,}], 'auth': jwt, 'hope': 200},
|
||||||
@ -176,6 +172,34 @@ def run(worker: Worker):
|
|||||||
],
|
],
|
||||||
'auth': jwt, 'hope': 400
|
'auth': jwt, 'hope': 400
|
||||||
},
|
},
|
||||||
|
# two tests that follow the rules
|
||||||
|
{
|
||||||
|
'init': [
|
||||||
|
'get', '/message/from_id', {'start': 1, 'channel': 3}
|
||||||
|
],
|
||||||
|
'auth': jwt, 'hope': 200, 'body': True
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'init': [
|
||||||
|
'get', '/message/from_id', {'start':1, 'channel':3, 'limit':2}
|
||||||
|
],
|
||||||
|
'auth': jwt, 'hope': 200, 'body': True
|
||||||
|
},
|
||||||
|
# tests that don't follow the api's rules
|
||||||
|
{
|
||||||
|
# channel doesn't exist so a 404 seems to be inorder
|
||||||
|
'init': [
|
||||||
|
'get', '/message/from_id', {'start': 1, 'channel':9}
|
||||||
|
],
|
||||||
|
'auth': jwt, 'hope': 404
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'init': [
|
||||||
|
# good channel but id is tooo high
|
||||||
|
'get', '/message/from_id', {'start': 5, 'channel':3}
|
||||||
|
],
|
||||||
|
'auth': jwt, 'hope': 404
|
||||||
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
for test in message_tests:
|
for test in message_tests:
|
||||||
|
Loading…
Reference in New Issue
Block a user