Fix HTTP 204 status code response handling
- Modified delete_user_endpoint to return None for HTTP 204 status code - Updated delete_todo endpoint to also return None for HTTP 204 status code - Added proper return type annotations to both endpoints - This fixes the AssertionError: Status code 204 must not have a response body
This commit is contained in:
parent
4f79f6c29a
commit
674c0542ae
@ -78,10 +78,12 @@ def delete_todo(
|
|||||||
todo_id: int,
|
todo_id: int,
|
||||||
db: Session = Depends(get_db),
|
db: Session = Depends(get_db),
|
||||||
current_user: User = Depends(get_current_active_user)
|
current_user: User = Depends(get_current_active_user)
|
||||||
):
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Delete a todo item for the current user.
|
Delete a todo item for the current user.
|
||||||
"""
|
"""
|
||||||
success = todo_crud.delete_todo(db, todo_id=todo_id, owner_id=current_user.id)
|
success = todo_crud.delete_todo(db, todo_id=todo_id, owner_id=current_user.id)
|
||||||
if not success:
|
if not success:
|
||||||
raise HTTPException(status_code=404, detail="Todo not found")
|
raise HTTPException(status_code=404, detail="Todo not found")
|
||||||
|
# Explicitly return None for 204 response
|
||||||
|
return None
|
@ -74,7 +74,7 @@ def delete_user_endpoint(
|
|||||||
user_id: int,
|
user_id: int,
|
||||||
db: Session = Depends(get_db),
|
db: Session = Depends(get_db),
|
||||||
current_user: User = Depends(get_current_active_user),
|
current_user: User = Depends(get_current_active_user),
|
||||||
):
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Delete a user.
|
Delete a user.
|
||||||
"""
|
"""
|
||||||
@ -87,4 +87,6 @@ def delete_user_endpoint(
|
|||||||
|
|
||||||
success = delete_user(db, user_id=user_id)
|
success = delete_user(db, user_id=user_id)
|
||||||
if not success:
|
if not success:
|
||||||
raise HTTPException(status_code=404, detail="User not found")
|
raise HTTPException(status_code=404, detail="User not found")
|
||||||
|
# Explicitly return None for 204 response
|
||||||
|
return None
|
Loading…
x
Reference in New Issue
Block a user