mirror of
https://github.com/LukeHagar/connexion.git
synced 2025-12-10 04:19:37 +00:00
#48 validate integer, number and boolean query parameters
This commit is contained in:
@@ -330,10 +330,26 @@ def test_single_route(app):
|
||||
def test_parameter_validation(app):
|
||||
app_client = app.app.test_client()
|
||||
|
||||
url = '/v1.0/test_parameter_validation'
|
||||
|
||||
for invalid_date in '', 'foo', '2015-01-01T12:00:00Z':
|
||||
response = app_client.get('/v1.0/test_parameter_validation', query_string={'date': invalid_date}) # type: flask.Response
|
||||
response = app_client.get(url, query_string={'date': invalid_date}) # type: flask.Response
|
||||
assert response.status_code == 400
|
||||
assert response.content_type == 'application/problem+json'
|
||||
|
||||
response = app_client.get('/v1.0/test_parameter_validation', query_string={'date': '2015-08-26'}) # type: flask.Response
|
||||
response = app_client.get(url, query_string={'date': '2015-08-26'}) # type: flask.Response
|
||||
assert response.status_code == 200
|
||||
|
||||
for invalid_int in '', 'foo', '0.1':
|
||||
response = app_client.get(url, query_string={'int': invalid_int}) # type: flask.Response
|
||||
assert response.status_code == 400
|
||||
|
||||
response = app_client.get(url, query_string={'int': '123'}) # type: flask.Response
|
||||
assert response.status_code == 200
|
||||
|
||||
for invalid_bool in '', 'foo', 'yes', 'False':
|
||||
response = app_client.get(url, query_string={'bool': invalid_bool}) # type: flask.Response
|
||||
assert response.status_code == 400
|
||||
|
||||
response = app_client.get(url, query_string={'bool': 'true'}) # type: flask.Response
|
||||
assert response.status_code == 200
|
||||
|
||||
Reference in New Issue
Block a user