Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Category Delete API Endpoint #9

Open
3 tasks
Pythonian opened this issue Jul 25, 2024 · 0 comments
Open
3 tasks

Category Delete API Endpoint #9

Pythonian opened this issue Jul 25, 2024 · 0 comments

Comments

@Pythonian
Copy link
Owner

Description

Develop an endpoint to handle requests to soft delete a category. Instead of removing the category from the database, this will set a flag to indicate that the category is deleted.

Acceptance Criteria

  • The endpoint allows soft deletion of a category by setting its is_deleted flag to True.
  • The endpoint validates that the category exists and is not already marked as deleted.
  • Returns a 204 No Content status code if the deletion is successful.
  • Handles errors appropriately, returning the correct status codes for not found or other issues.

Requirements

  • Implement API endpoint for soft deleting a category.
  • Validate that the category exists and is not already marked as deleted.
  • Handle unexpected errors and return the appropriate status code.

Expected Outcome

  • Users should be able to send a request to soft delete a category.
  • Users should receive appropriate status codes based on the outcome of the request.

Endpoints

[DELETE] /api/v1/categories/{id}

  • Description: Soft deletes a category by setting its is_deleted flag to True.

  • Request Path Parameter:

    • id: The ID of the category to be deleted.
  • Success Response:

    • Status: 204 No Content
  • Error Response:

    • Status: 404 Not Found

    • Body:

      {
          "detail": "Category not found."
      }
  • Internal Server Error Response:

    • Status: 500 Internal Server Error

    • Body:

      {
          "error": "Internal server error."
      }

Testing

Test Scenarios

  1. Successful Soft Deletion

    • Ensure that the endpoint successfully soft deletes a category.
    • Verify that the response includes a 204 No Content status code.
  2. Not Found Error

    • Simulate a request to delete a category that does not exist.
    • Verify that the endpoint returns a 404 Not Found status code and an appropriate error message.
  3. Internal Server Error

    • Simulate an internal server error to raise an exception.
    • Verify that the endpoint returns a 500 Internal Server Error status code and an appropriate error message.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant