@@ -124,30 +124,36 @@ def test_get_pets(self, spec):
124124 }
125125
126126 request = RequestMock (
127- host_url , 'get ' , '/pets' ,
127+ host_url , 'GET ' , '/pets' ,
128128 path_pattern = path_pattern , args = query_params ,
129129 )
130130
131131 parameters = request .get_parameters (spec )
132+ body = request .get_body (spec )
132133
133134 assert parameters == {
134135 'query' : {
135136 'limit' : 20 ,
136137 'ids' : [12 , 13 ],
137138 }
138139 }
140+ assert body is None
139141
140142 def test_get_pets_raises_missing_required_param (self , spec ):
141143 host_url = 'http://petstore.swagger.io/v1'
142144 path_pattern = '/v1/pets'
143145 request = RequestMock (
144- host_url , 'get ' , '/pets' ,
146+ host_url , 'GET ' , '/pets' ,
145147 path_pattern = path_pattern ,
146148 )
147149
148150 with pytest .raises (MissingParameterError ):
149151 request .get_parameters (spec )
150152
153+ body = request .get_body (spec )
154+
155+ assert body is None
156+
151157 def test_get_pets_failed_to_cast (self , spec ):
152158 host_url = 'http://petstore.swagger.io/v1'
153159 path_pattern = '/v1/pets'
@@ -156,17 +162,19 @@ def test_get_pets_failed_to_cast(self, spec):
156162 }
157163
158164 request = RequestMock (
159- host_url , 'get ' , '/pets' ,
165+ host_url , 'GET ' , '/pets' ,
160166 path_pattern = path_pattern , args = query_params ,
161167 )
162168
163169 parameters = request .get_parameters (spec )
170+ body = request .get_body (spec )
164171
165172 assert parameters == {
166173 'query' : {
167174 'limit' : 'non_integer_value' ,
168175 }
169176 }
177+ assert body is None
170178
171179 def test_get_pets_empty_value (self , spec ):
172180 host_url = 'http://petstore.swagger.io/v1'
@@ -176,17 +184,19 @@ def test_get_pets_empty_value(self, spec):
176184 }
177185
178186 request = RequestMock (
179- host_url , 'get ' , '/pets' ,
187+ host_url , 'GET ' , '/pets' ,
180188 path_pattern = path_pattern , args = query_params ,
181189 )
182190
183191 parameters = request .get_parameters (spec )
192+ body = request .get_body (spec )
184193
185194 assert parameters == {
186195 'query' : {
187196 'limit' : None ,
188197 }
189198 }
199+ assert body is None
190200
191201 def test_get_pets_none_value (self , spec ):
192202 host_url = 'http://petstore.swagger.io/v1'
@@ -196,7 +206,7 @@ def test_get_pets_none_value(self, spec):
196206 }
197207
198208 request = RequestMock (
199- host_url , 'get ' , '/pets' ,
209+ host_url , 'GET ' , '/pets' ,
200210 path_pattern = path_pattern , args = query_params ,
201211 )
202212
@@ -208,6 +218,10 @@ def test_get_pets_none_value(self, spec):
208218 }
209219 }
210220
221+ body = request .get_body (spec )
222+
223+ assert body is None
224+
211225 def test_post_pets (self , spec , spec_dict ):
212226 host_url = 'http://petstore.swagger.io/v1'
213227 path_pattern = '/v1/pets'
@@ -226,21 +240,25 @@ def test_post_pets(self, spec, spec_dict):
226240 data = json .dumps (data_json )
227241
228242 request = RequestMock (
229- host_url , 'post ' , '/pets' ,
243+ host_url , 'POST ' , '/pets' ,
230244 path_pattern = path_pattern , data = data ,
231245 )
232246
233- pet = request .get_body (spec )
247+ parameters = request .get_parameters (spec )
248+
249+ assert parameters == {}
250+
251+ body = request .get_body (spec )
234252
235253 schemas = spec_dict ['components' ]['schemas' ]
236254 pet_model = schemas ['PetCreate' ]['x-model' ]
237255 address_model = schemas ['Address' ]['x-model' ]
238- assert pet .__class__ .__name__ == pet_model
239- assert pet .name == pet_name
240- assert pet .tag == pet_tag
241- assert pet .address .__class__ .__name__ == address_model
242- assert pet .address .street == pet_street
243- assert pet .address .city == pet_city
256+ assert body .__class__ .__name__ == pet_model
257+ assert body .name == pet_name
258+ assert body .tag == pet_tag
259+ assert body .address .__class__ .__name__ == address_model
260+ assert body .address .street == pet_street
261+ assert body .address .city == pet_city
244262
245263 def test_post_pets_raises_invalid_content_type (self , spec ):
246264 host_url = 'http://petstore.swagger.io/v1'
@@ -252,10 +270,14 @@ def test_post_pets_raises_invalid_content_type(self, spec):
252270 data = json .dumps (data_json )
253271
254272 request = RequestMock (
255- host_url , 'post ' , '/pets' ,
273+ host_url , 'POST ' , '/pets' ,
256274 path_pattern = path_pattern , data = data , content_type = 'text/html' ,
257275 )
258276
277+ parameters = request .get_parameters (spec )
278+
279+ assert parameters == {}
280+
259281 with pytest .raises (InvalidContentTypeError ):
260282 request .get_body (spec )
261283
@@ -269,10 +291,13 @@ def test_post_pets_raises_invalid_server_error(self, spec):
269291 data = json .dumps (data_json )
270292
271293 request = RequestMock (
272- host_url , 'post ' , '/pets' ,
294+ host_url , 'POST ' , '/pets' ,
273295 path_pattern = path_pattern , data = data , content_type = 'text/html' ,
274296 )
275297
298+ with pytest .raises (InvalidServerError ):
299+ request .get_parameters (spec )
300+
276301 with pytest .raises (InvalidServerError ):
277302 request .get_body (spec )
278303
@@ -283,7 +308,7 @@ def test_get_pet(self, spec):
283308 'petId' : '1' ,
284309 }
285310 request = RequestMock (
286- host_url , 'get ' , '/pets/1' ,
311+ host_url , 'GET ' , '/pets/1' ,
287312 path_pattern = path_pattern , view_args = view_args ,
288313 )
289314
@@ -294,3 +319,7 @@ def test_get_pet(self, spec):
294319 'petId' : 1 ,
295320 }
296321 }
322+
323+ body = request .get_body (spec )
324+
325+ assert body is None
0 commit comments