@@ -340,6 +340,7 @@ def test_validate_form(app):
340
340
class Pet :
341
341
name : str
342
342
alter_ego : List [str ]
343
+ description : Optional [str ] = None
343
344
344
345
@app .post ("/function" )
345
346
@validate (form = Pet )
@@ -348,6 +349,7 @@ async def handler(_, body: Pet):
348
349
{
349
350
"is_pet" : isinstance (body , Pet ),
350
351
"pet" : {"name" : body .name , "alter_ego" : body .alter_ego },
352
+ "description" : body .description if body .description else "" ,
351
353
}
352
354
)
353
355
@@ -359,18 +361,21 @@ async def post(self, _, body: Pet):
359
361
{
360
362
"is_pet" : isinstance (body , Pet ),
361
363
"pet" : {"name" : body .name , "alter_ego" : body .alter_ego },
364
+ "description" : body .description if body .description else "" ,
362
365
}
363
366
)
364
367
365
368
_ , response = app .test_client .post ("/function" , data = SNOOPY_DATA )
366
369
assert response .status == 200
367
370
assert response .json ["is_pet" ]
368
371
assert response .json ["pet" ] == SNOOPY_DATA
372
+ assert response .json ["description" ] == ""
369
373
370
374
_ , response = app .test_client .post ("/method" , data = SNOOPY_DATA )
371
375
assert response .status == 200
372
376
assert response .json ["is_pet" ]
373
377
assert response .json ["pet" ] == SNOOPY_DATA
378
+ assert response .json ["description" ] == ""
374
379
375
380
376
381
def test_validate_query (app ):
0 commit comments