@@ -40,9 +40,10 @@ class BookCookie(BaseModel):
4040
4141
4242class BookHeader (BaseModel ):
43- Hello1 : str = Field ("what's up" , max_length = 12 , description = ' sds' )
43+ Hello1 : str = Field ("what's up" , max_length = 12 , description = " sds" )
4444 # required
45- hello2 : str = Field (..., max_length = 12 , description = 'sds' )
45+ hello2 : str = Field (..., max_length = 12 , description = "sds" )
46+ api_key : str = Field (..., description = "API Key" )
4647
4748
4849def decorator (func ):
@@ -72,7 +73,7 @@ def api_error_json(body: BookBody):
7273 return {"code" : 0 , "message" : "ok" }
7374
7475
75- @app .get (' /header' )
76+ @app .get (" /header" )
7677def get_book (header : BookHeader ):
7778 return header .dict ()
7879
@@ -97,7 +98,7 @@ def test_form(client):
9798 "string" : "a" ,
9899 "string_list" : ["a" , "b" , "c" ]
99100 }
100- r = client .post ("/form" , data = data , content_type = ' multipart/form-data' )
101+ r = client .post ("/form" , data = data , content_type = " multipart/form-data" )
101102 assert r .status_code == 200
102103
103104
@@ -113,7 +114,7 @@ def test_cookie(client):
113114
114115
115116def test_header (client ):
116- headers = {' Hello1' : ' 111' , ' hello2' : ' 222' }
117+ headers = {" Hello1" : " 111" , " hello2" : " 222" , "api_key" : "333" }
117118 resp = client .get ("/header" , headers = headers )
118119 print (resp .json )
119120 assert resp .status_code == 200
0 commit comments