<s> import json <EOL> from io import BytesIO <EOL> def test_parameter_validation ( simple_app ) : <EOL> app_client = simple_app . app . test_client ( ) <EOL> url = '<STR_LIT>' <EOL> response = app_client . get ( url , query_string = { '<STR_LIT:date>' : '<STR_LIT>' } ) <EOL> assert response . status_code == <NUM_LIT:200> <EOL> for invalid_int in '<STR_LIT>' , '<STR_LIT:foo>' , '<STR_LIT>' : <EOL> response = app_client . get ( url , query_string = { '<STR_LIT:int>' : invalid_int } ) <EOL> assert response . status_code == <NUM_LIT> <EOL> response = app_client . get ( url , query_string = { '<STR_LIT:int>' : '<STR_LIT>' } ) <EOL> assert response . status_code == <NUM_LIT:200> <EOL> for invalid_bool in '<STR_LIT>' , '<STR_LIT:foo>' , '<STR_LIT:yes>' : <EOL> response = app_client . get ( url , query_string = { '<STR_LIT:bool>' : invalid_bool } ) <EOL> assert response . status_code == <NUM_LIT> <EOL> response = app_client . get ( url , query_string = { '<STR_LIT:bool>' : '<STR_LIT:true>' } ) <EOL> assert response . status_code == <NUM_LIT:200> <EOL> def test_required_query_param ( simple_app ) : <EOL> app_client = simple_app . app . test_client ( ) <EOL> url = '<STR_LIT>' <EOL> response = app_client . get ( url ) <EOL> assert response . status_code == <NUM_LIT> <EOL> response = app_client . get ( url , query_string = { '<STR_LIT:n>' : '<STR_LIT>' } ) <EOL> assert response . status_code == <NUM_LIT:200> <EOL> def test_array_query_param ( simple_app ) : <EOL> app_client = simple_app . app . test_client ( ) <EOL> headers = { '<STR_LIT>' : '<STR_LIT:application/json>' } <EOL> url = '<STR_LIT>' <EOL> response = app_client . get ( url , headers = headers ) <EOL> array_response = json . loads ( response . data . decode ( ) ) <EOL> assert array_response == [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> url = '<STR_LIT>' <EOL> response = app_client . get ( url , headers = headers ) <EOL> array_response = json . loads ( response . data . decode ( ) ) <EOL> assert array_response == [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] <EOL> url = '<STR_LIT>' <EOL> response = app_client . get ( url , headers = headers ) <EOL> array_response = json . loads ( response . data . decode ( ) ) <EOL> assert array_response == [ "<STR_LIT>" ] <EOL> def test_path_parameter_someint ( simple_app ) : <EOL> app_client = simple_app . app . test_client ( ) <EOL> resp = app_client . get ( '<STR_LIT>' ) <EOL> assert resp . data . decode ( ) == '<STR_LIT>' <EOL> resp = app_client . get ( '<STR_LIT>' ) <EOL> assert resp . status_code == <NUM_LIT> <EOL> def test_path_parameter_somefloat ( simple_app ) : <EOL> app_client = simple_app . app . test_client ( ) <EOL> resp = app_client . get ( '<STR_LIT>' ) <EOL> assert resp . data . decode ( ) == '<STR_LIT>' <EOL> resp = app_client . get ( '<STR_LIT>' ) <EOL> assert resp . status_code == <NUM_LIT> <EOL> def test_default_param ( simple_app ) : <EOL> app_client = simple_app . app . test_client ( ) <EOL> resp = app_client . get ( '<STR_LIT>' ) <EOL> assert resp . status_code == <NUM_LIT:200> <EOL> response = json . loads ( resp . data . decode ( ) ) <EOL> assert response [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> def test_falsy_param ( simple_app ) : <EOL> app_client = simple_app . app . test_client ( ) <EOL> resp = app_client . get ( '<STR_LIT>' , query_string = { '<STR_LIT>' : <NUM_LIT:0> } ) <EOL> assert resp . status_code == <NUM_LIT:200> <EOL> response = json . loads ( resp . data . decode ( ) ) <EOL> assert response == <NUM_LIT:0> <EOL> resp = app_client . get ( '<STR_LIT>' ) <EOL> assert resp . status_code == <NUM_LIT:200> <EOL> response = json . loads ( resp . data . decode ( ) ) <EOL> assert response == <NUM_LIT:1> <EOL> def test_formdata_param ( simple_app ) : <EOL> app_client = simple_app . app . test_client ( ) <EOL> resp = app_client . post ( '<STR_LIT>' , <EOL> data = { '<STR_LIT>' : '<STR_LIT:test>' } ) <EOL> assert resp . status_code == <NUM_LIT:200> <EOL> response = json . loads ( resp . data . decode ( ) ) <EOL> assert response == '<STR_LIT:test>' <EOL> def test_formdata_bad_request ( simple_app ) : <EOL> app_client = simple_app . app . test_client ( ) <EOL> resp = app_client . post ( '<STR_LIT>' ) <EOL> assert resp . status_code == <NUM_LIT> <EOL> response = json . loads ( resp . data . decode ( ) ) <EOL> assert response [ '<STR_LIT>' ] == "<STR_LIT>" <EOL> def test_formdata_missing_param ( simple_app ) : <EOL> app_client = simple_app . app . test_client ( ) <EOL> resp = app_client . post ( '<STR_LIT>' , <EOL> data = { '<STR_LIT>' : '<STR_LIT:test>' } ) <EOL> assert resp . status_code == <NUM_LIT:200> <EOL> def test_formdata_file_upload ( simple_app ) : <EOL> app_client = simple_app . app . test_client ( ) <EOL> resp = app_client . post ( '<STR_LIT>' , <EOL> data = { '<STR_LIT>' : ( BytesIO ( b'<STR_LIT>' ) , '<STR_LIT>' ) } ) <EOL> assert resp . status_code == <NUM_LIT:200> <EOL> response = json . loads ( resp . data . decode ( ) ) <EOL> assert response == { '<STR_LIT>' : '<STR_LIT>' } <EOL> def test_formdata_file_upload_bad_request ( simple_app ) : <EOL> app_client = simple_app . app . test_client ( ) <EOL> resp = app_client . post ( '<STR_LIT>' ) <EOL> assert resp . status_code == <NUM_LIT> <EOL> response = json . loads ( resp . data . decode ( ) ) <EOL> assert response [ '<STR_LIT>' ] == "<STR_LIT>" <EOL> def test_formdata_file_upload_missing_param ( simple_app ) : <EOL> app_client = simple_app . app . test_client ( ) <EOL> resp = app_client . post ( '<STR_LIT>' , <EOL> data = { '<STR_LIT>' : ( BytesIO ( b'<STR_LIT>' ) , '<STR_LIT>' ) } ) <EOL> assert resp . status_code == <NUM_LIT:200> <EOL> def test_bool_as_default_param ( simple_app ) : <EOL> app_client = simple_app . app . test_client ( ) <EOL> resp = app_client . get ( '<STR_LIT>' ) <EOL> assert resp . status_code == <NUM_LIT:200> <EOL> resp = app_client . get ( '<STR_LIT>' , query_string = { '<STR_LIT>' : True } ) <EOL> assert resp . status_code == <NUM_LIT:200> <EOL> response = json . loads ( resp . data . decode ( ) ) <EOL> assert response is True <EOL> def test_bool_param ( simple_app ) : <EOL> app_client = simple_app . app . test_client ( ) <EOL> resp = app_client . get ( '<STR_LIT>' , query_string = { '<STR_LIT>' : True } ) <EOL> assert resp . status_code == <NUM_LIT:200> <EOL> response = json . loads ( resp . data . decode ( ) ) <EOL> assert response is True <EOL> resp = app_client . get ( '<STR_LIT>' , query_string = { '<STR_LIT>' : False } ) <EOL> assert resp . status_code == <NUM_LIT:200> <EOL> response = json . loads ( resp . data . decode ( ) ) <EOL> assert response is False <EOL> def test_bool_array_param ( simple_app ) : <EOL> app_client = simple_app . app . test_client ( ) <EOL> resp = app_client . get ( '<STR_LIT>' ) <EOL> assert resp . status_code == <NUM_LIT:200> <EOL> response = json . loads ( resp . data . decode ( ) ) <EOL> assert response is True <EOL> app_client = simple_app . app . test_client ( ) <EOL> resp = app_client . get ( '<STR_LIT>' ) <EOL> assert resp . status_code == <NUM_LIT:200> <EOL> response = json . loads ( resp . data . decode ( ) ) <EOL> assert response is False <EOL> app_client = simple_app . app . test_client ( ) <EOL> resp = app_client . get ( '<STR_LIT>' ) <EOL> assert resp . status_code == <NUM_LIT:200> <EOL> def test_required_param_miss_config ( simple_app ) : <EOL> app_client = simple_app . app . test_client ( ) <EOL> resp = app_client . get ( '<STR_LIT>' ) <EOL> assert resp . status_code == <NUM_LIT> <EOL> resp = app_client . get ( '<STR_LIT>' , query_string = { '<STR_LIT>' : '<STR_LIT:test>' } ) <EOL> assert resp . status_code == <NUM_LIT:200> <EOL> resp = app_client . get ( '<STR_LIT>' ) <EOL> assert resp . status_code == <NUM_LIT> <EOL> def test_parameters_defined_in_path_level ( simple_app ) : <EOL> app_client = simple_app . app . test_client ( ) <EOL> resp = app_client . get ( '<STR_LIT>' ) <EOL> assert resp . status_code == <NUM_LIT:200> <EOL> assert json . loads ( resp . data . decode ( ) ) == [ "<STR_LIT>" ] <EOL> resp = app_client . get ( '<STR_LIT>' ) <EOL> assert resp . status_code == <NUM_LIT> <EOL> def test_array_in_path ( simple_app ) : <EOL> app_client = simple_app . app . test_client ( ) <EOL> resp = app_client . get ( '<STR_LIT>' ) <EOL> assert json . loads ( resp . data . decode ( ) ) == [ "<STR_LIT>" ] <EOL> resp = app_client . get ( '<STR_LIT>' ) <EOL> assert json . loads ( resp . data . decode ( ) ) == [ "<STR_LIT>" , "<STR_LIT>" ] <EOL> def test_nullable_parameter ( simple_app ) : <EOL> app_client = simple_app . app . test_client ( ) <EOL> resp = app_client . get ( '<STR_LIT>' ) <EOL> assert json . loads ( resp . data . decode ( ) ) == '<STR_LIT>' <EOL> resp = app_client . get ( '<STR_LIT>' ) <EOL> assert json . loads ( resp . data . decode ( ) ) == '<STR_LIT>' <EOL> time_start = <NUM_LIT> <EOL> resp = app_client . get ( <EOL> '<STR_LIT>' . format ( time_start ) ) <EOL> assert json . loads ( resp . data . decode ( ) ) == time_start <EOL> resp = app_client . post ( '<STR_LIT>' , data = { "<STR_LIT>" : '<STR_LIT:None>' } ) <EOL> assert json . loads ( resp . data . decode ( ) ) == '<STR_LIT>' <EOL> resp = app_client . post ( '<STR_LIT>' , data = { "<STR_LIT>" : '<STR_LIT:null>' } ) <EOL> assert json . loads ( resp . data . decode ( ) ) == '<STR_LIT>' <EOL> resp = app_client . put ( '<STR_LIT>' , data = "<STR_LIT:null>" ) <EOL> assert json . loads ( resp . data . decode ( ) ) == '<STR_LIT>' <EOL> resp = app_client . put ( '<STR_LIT>' , data = "<STR_LIT:None>" ) <EOL> assert json . loads ( resp . data . decode ( ) ) == '<STR_LIT>' </s>
