|
7 | 7 | - GET /players/{player_id} |
8 | 8 | - GET /players/squadnumber/{squad_number} |
9 | 9 | - POST /players/ |
10 | | -- PUT /players/{player_id} |
11 | | -- DELETE /players/{player_id} |
| 10 | +- PUT /players/squadnumber/{squad_number} |
| 11 | +- DELETE /players/squadnumber/{squad_number} |
12 | 12 |
|
13 | 13 | Validates: |
14 | 14 | - Status codes, response bodies, headers (e.g., X-Cache) |
@@ -191,66 +191,68 @@ def test_request_post_player_body_nonexistent_response_status_created(client): |
191 | 191 | assert UUID(body["id"]).version == 4 # UUID v4 (API-created) |
192 | 192 |
|
193 | 193 |
|
194 | | -# PUT /players/{player_id} ----------------------------------------------------- |
| 194 | +# PUT /players/squadnumber/{squad_number} -------------------------------------- |
195 | 195 |
|
196 | 196 |
|
197 | | -def test_request_put_player_id_existing_body_empty_response_status_unprocessable( |
| 197 | +def test_request_put_player_squadnumber_existing_body_empty_response_status_unprocessable( |
198 | 198 | client, |
199 | 199 | ): |
200 | | - """PUT /players/{player_id} with empty body returns 422 Unprocessable Entity""" |
| 200 | + """PUT /players/squadnumber/{squad_number} with empty body returns 422 Unprocessable Entity""" |
201 | 201 | # Arrange |
202 | | - player_id = existing_player().id |
| 202 | + squad_number = existing_player().squad_number |
203 | 203 | # Act |
204 | | - response = client.put(PATH + str(player_id), json={}) |
| 204 | + response = client.put(PATH + "squadnumber/" + str(squad_number), json={}) |
205 | 205 | # Assert |
206 | 206 | assert response.status_code == 422 |
207 | 207 |
|
208 | 208 |
|
209 | | -def test_request_put_player_id_unknown_response_status_not_found(client): |
210 | | - """PUT /players/{player_id} with unknown ID returns 404 Not Found""" |
| 209 | +def test_request_put_player_squadnumber_unknown_response_status_not_found(client): |
| 210 | + """PUT /players/squadnumber/{squad_number} with unknown number returns 404 Not Found""" |
211 | 211 | # Arrange |
212 | | - player_id = unknown_player().id |
| 212 | + squad_number = unknown_player().squad_number |
213 | 213 | player = unknown_player() |
214 | 214 | # Act |
215 | | - response = client.put(PATH + str(player_id), json=player.__dict__) |
| 215 | + response = client.put( |
| 216 | + PATH + "squadnumber/" + str(squad_number), json=player.__dict__ |
| 217 | + ) |
216 | 218 | # Assert |
217 | 219 | assert response.status_code == 404 |
218 | 220 |
|
219 | 221 |
|
220 | | -def test_request_put_player_id_existing_response_status_no_content(client): |
221 | | - """PUT /players/{player_id} with existing ID returns 204 No Content""" |
| 222 | +def test_request_put_player_squadnumber_existing_response_status_no_content(client): |
| 223 | + """PUT /players/squadnumber/{squad_number} with existing number returns 204 No Content""" |
222 | 224 | # Arrange |
223 | | - player_id = existing_player().id |
| 225 | + squad_number = existing_player().squad_number |
224 | 226 | player = existing_player() |
225 | 227 | player.first_name = "Emiliano" |
226 | 228 | player.middle_name = "" |
227 | 229 | # Act |
228 | | - response = client.put(PATH + str(player_id), json=player.__dict__) |
| 230 | + response = client.put( |
| 231 | + PATH + "squadnumber/" + str(squad_number), json=player.__dict__ |
| 232 | + ) |
229 | 233 | # Assert |
230 | 234 | assert response.status_code == 204 |
231 | 235 |
|
232 | 236 |
|
233 | | -# DELETE /players/{player_id} -------------------------------------------------- |
| 237 | +# DELETE /players/squadnumber/{squad_number} ----------------------------------- |
234 | 238 |
|
235 | 239 |
|
236 | | -def test_request_delete_player_id_unknown_response_status_not_found(client): |
237 | | - """DELETE /players/{player_id} with unknown ID returns 404 Not Found""" |
| 240 | +def test_request_delete_player_squadnumber_unknown_response_status_not_found(client): |
| 241 | + """DELETE /players/squadnumber/{squad_number} with unknown number returns 404 Not Found""" |
238 | 242 | # Arrange |
239 | | - player_id = unknown_player().id |
| 243 | + squad_number = unknown_player().squad_number |
240 | 244 | # Act |
241 | | - response = client.delete(PATH + str(player_id)) |
| 245 | + response = client.delete(PATH + "squadnumber/" + str(squad_number)) |
242 | 246 | # Assert |
243 | 247 | assert response.status_code == 404 |
244 | 248 |
|
245 | 249 |
|
246 | | -def test_request_delete_player_id_existing_response_status_no_content(client): |
247 | | - """DELETE /players/{player_id} with existing UUID returns 204 No Content""" |
248 | | - # Arrange — create the player to be deleted, then resolve its UUID |
| 250 | +def test_request_delete_player_squadnumber_existing_response_status_no_content(client): |
| 251 | + """DELETE /players/squadnumber/{squad_number} with existing number returns 204 No Content""" |
| 252 | + # Arrange — create the player to be deleted |
249 | 253 | player = nonexistent_player() |
250 | 254 | client.post(PATH, json=player.__dict__) |
251 | | - lookup_response = client.get(PATH + "squadnumber/" + str(player.squad_number)) |
252 | | - player_id = lookup_response.json()["id"] |
253 | 255 | # Act |
254 | | - response = client.delete(PATH + str(player_id)) |
| 256 | + response = client.delete(PATH + "squadnumber/" + str(player.squad_number)) |
255 | 257 | # Assert |
256 | 258 | assert response.status_code == 204 |
0 commit comments