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

Fix: Ensure Consistent Success Response for Testimonial Deletion Endpoints #1137

Open
Dafinci01 opened this issue Feb 28, 2025 · 2 comments
Open

Comments

@Dafinci01
Copy link

Dafinci01 commented Feb 28, 2025

Description

Currently, the delete_testimonial and delete_all_testimonials endpoints do not return a response upon successful deletion, leading to inconsistencies in API behavior. This update ensures that all testimonial deletion endpoints return a consistent JSON success response.


Changes to be Implemented

1. Routes (testimonial.py)

  • Modify the delete_testimonial endpoint to return a JSON success response after deleting a specific testimonial.
  • Modify the delete_all_testimonials endpoint to return a JSON success response after deleting all testimonials.

2. Services (testimonial_service.py)

  • Ensure that the delete functions include meaningful error handling for:
    • Invalid testimonial IDs
    • Failed deletion operations

3. Models (testimonial.py)

  • No structural changes.
  • Ensure that deletions correctly reflect in the database.

Action Items

  • Update delete_testimonial to return a JSON response confirming deletion.
  • Update delete_all_testimonials to return a JSON response confirming all testimonials were deleted.
  • Implement error handling for invalid testimonial IDs or failed deletions.
  • Write unit and integration tests to verify functionality.

Expected Outcome

Users will receive a confirmation message when a testimonial is deleted, ensuring API consistency across all deletion endpoints.


API Endpoint Changes

1. Delete a Testimonial

  • Endpoint: DELETE /testimonials/{testimonial_id}
  • Description: Deletes a specific testimonial by ID.

Request Example:

DELETE /testimonials/12345

Response Example:

{
  "status": "success",
  "message": "Testimonial 12345 deleted successfully"
}

2. Delete All Testimonials

  • Endpoint: DELETE /testimonials/
  • Description: Deletes all testimonials from the database.

Request Example:

DELETE /testimonials/

Response Example:

{
  "status": "success",
  "message": "All testimonials deleted successfully"
}

Testing Requirements

  • Verify that deleting a single testimonial returns a success response.
  • Verify that deleting all testimonials returns a success response.
  • Validate proper error handling when deleting a non-existent testimonial.
  • Ensure API consistency across all delete endpoint
@Dafinci01
Copy link
Author

@Ayobamidele
Copy link
Contributor

Did you look at the standard response expected in the stage 4 task?

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

2 participants