[tests] fix tests so the data is sent in json
This commit is contained in:
parent
dd83a337e9
commit
b7c5704c95
|
@ -99,6 +99,7 @@ def route_decorator(fct: FunctionType) -> Coroutine:
|
|||
logger.debug('Return type {} (defaults: {})'.format(ret_type,
|
||||
fct_args_defaults_dict))
|
||||
try:
|
||||
logger.debug('FCT_ARGS***** %s', fct_args)
|
||||
if ret_type == 'json':
|
||||
return ORJSONResponse(fct(**fct_args))
|
||||
|
||||
|
|
|
@ -47,7 +47,8 @@ ACLS = {
|
|||
'foo', 'baz'
|
||||
},
|
||||
'optional': {
|
||||
'truebidoo'
|
||||
'truebidoo',
|
||||
'z'
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -32,7 +32,7 @@ class TestDummyDomain(TestDomain):
|
|||
assert isinstance(res.content.decode(), str)
|
||||
assert res.headers['content-type'].split(';')[0] == 'text/html'
|
||||
|
||||
res = self.client.request('post', '/ret_type/h24/config', data={
|
||||
res = self.client.request('post', '/ret_type/h24/config', json={
|
||||
'trou': 'glet'
|
||||
})
|
||||
assert res.status_code == 200
|
||||
|
@ -53,24 +53,27 @@ class TestDummyDomain(TestDomain):
|
|||
|
||||
def test_arguments_post_routes(self):
|
||||
arg_dict = {}
|
||||
res = self.client.request('post', '/arguments', data=arg_dict)
|
||||
res = self.client.request('post', '/arguments', json=arg_dict)
|
||||
|
||||
assert res.status_code == 400
|
||||
|
||||
arg_dict = {'foo': '1', 'bar': '3'}
|
||||
res = self.client.request('post', '/arguments', data=arg_dict)
|
||||
res = self.client.request('post', '/arguments', json=arg_dict)
|
||||
|
||||
assert res.status_code == 400
|
||||
|
||||
arg_dict = {'foo': '1', 'baz': '3'}
|
||||
res = self.client.request('post', '/arguments', data=arg_dict)
|
||||
res = self.client.request('post', '/arguments', json=arg_dict)
|
||||
|
||||
assert res.json() == arg_dict
|
||||
|
||||
arg_dict = {'foo': '1', 'baz': '3', 'truebidoo': '4'}
|
||||
res = self.client.request('post', '/arguments', data=arg_dict)
|
||||
res = self.client.request('post', '/arguments', json=arg_dict)
|
||||
|
||||
assert res.json() == arg_dict
|
||||
|
||||
res = self.client.request('post', '/arguments', data={ **arg_dict, 'y': '4'})
|
||||
res = self.client.request('post', '/arguments', json={ **arg_dict, 'y': '4'})
|
||||
assert res.json() == arg_dict
|
||||
|
||||
res = self.client.request('post', '/arguments', json={ **arg_dict, 'z': True})
|
||||
assert res.json() == {**arg_dict, 'z': True}
|
||||
|
|
Loading…
Reference in New Issue