[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,
|
logger.debug('Return type {} (defaults: {})'.format(ret_type,
|
||||||
fct_args_defaults_dict))
|
fct_args_defaults_dict))
|
||||||
try:
|
try:
|
||||||
|
logger.debug('FCT_ARGS***** %s', fct_args)
|
||||||
if ret_type == 'json':
|
if ret_type == 'json':
|
||||||
return ORJSONResponse(fct(**fct_args))
|
return ORJSONResponse(fct(**fct_args))
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,8 @@ ACLS = {
|
||||||
'foo', 'baz'
|
'foo', 'baz'
|
||||||
},
|
},
|
||||||
'optional': {
|
'optional': {
|
||||||
'truebidoo'
|
'truebidoo',
|
||||||
|
'z'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -32,7 +32,7 @@ class TestDummyDomain(TestDomain):
|
||||||
assert isinstance(res.content.decode(), str)
|
assert isinstance(res.content.decode(), str)
|
||||||
assert res.headers['content-type'].split(';')[0] == 'text/html'
|
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'
|
'trou': 'glet'
|
||||||
})
|
})
|
||||||
assert res.status_code == 200
|
assert res.status_code == 200
|
||||||
|
@ -53,24 +53,27 @@ class TestDummyDomain(TestDomain):
|
||||||
|
|
||||||
def test_arguments_post_routes(self):
|
def test_arguments_post_routes(self):
|
||||||
arg_dict = {}
|
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
|
assert res.status_code == 400
|
||||||
|
|
||||||
arg_dict = {'foo': '1', 'bar': '3'}
|
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
|
assert res.status_code == 400
|
||||||
|
|
||||||
arg_dict = {'foo': '1', 'baz': '3'}
|
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
|
assert res.json() == arg_dict
|
||||||
|
|
||||||
arg_dict = {'foo': '1', 'baz': '3', 'truebidoo': '4'}
|
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
|
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
|
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