@@ -24,6 +24,11 @@ async def test_int(request, test: int):
2424 async def test_str (request , test : str ):
2525 return response .json ({'test' : test })
2626
27+ @app .route ("/bool" , methods = ['GET' ])
28+ @parse_query_args
29+ async def test_bool (request , test : bool ):
30+ return response .json ({'test' : test })
31+
2732 @app .route ("/datetime" , methods = ['GET' ])
2833 @parse_query_args
2934 async def test_datetime (request , test : datetime .datetime ):
@@ -90,6 +95,23 @@ async def test_parse_int_fail(test_cli):
9095 assert resp .status == 400
9196
9297
98+ async def test_parse_bool_true_success (test_cli ):
99+ resp = await test_cli .get ('/bool?test=true' )
100+ assert resp .status == 200
101+ resp_json = await resp .json ()
102+ assert resp_json == {'test' : True }
103+
104+ async def test_parse_bool_false_success (test_cli ):
105+ resp = await test_cli .get ('/bool?test=false' )
106+ assert resp .status == 200
107+ resp_json = await resp .json ()
108+ assert resp_json == {'test' : False }
109+
110+ async def test_parse_bool_fail (test_cli ):
111+ resp = await test_cli .get ('/bool?test=not an bool' )
112+ assert resp .status == 400
113+
114+
93115async def test_parse_str_success (test_cli ):
94116 resp = await test_cli .get ('/str?test=hello' )
95117 assert resp .status == 200
0 commit comments