Pythonian / fastapi_web

Building a FastAPI application.
MIT License
0 stars 0 forks source link

Blog List API Endpoint #3

Open Pythonian opened 4 months ago

Pythonian commented 4 months ago

Description

Develop an endpoint to handle requests to fetch and return all blog post data. If the data is fetched successfully, it will be returned to the client with a 200 OK status. If an error occurs, an appropriate error status will be returned.

Acceptance Criteria

Requirements

Expected Outcome

Endpoints

[GET] /api/v1/blogs

Testing

Test Scenarios

  1. Successful Retrieval of Paginated Blog Posts

    • Ensure that the endpoint successfully retrieves a paginated list of blog posts.
    • Verify that the response includes the total count, next and previous page URLs, and the results with title, excerpt, publish date, and author for each blog post.
    • Confirm that the status code is 200 OK.
    • Confirm that the blog posts are ordered by the created date in descending order.
  2. No Blog Posts Present

    • Simulate a scenario where no blog posts are present in the database.
    • Confirm that the response body contains an empty list.
  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.
    • Confirm that the response body contains an appropriate error message.
  4. Invalid Page or Page Size Parameters

    • Send requests with invalid page or page_size parameters (e.g., negative numbers, non-integer values).
    • Verify that the endpoint returns a 400 Bad Request status code and an appropriate error message.
  5. Invalid Method

    • Send a request using an invalid HTTP method (e.g., POST) to the endpoint.
    • Verify that the endpoint returns a 405 Method Not Allowed status code.
  6. Soft-Deleted Blog Post Access Control

    • Ensure that soft-deleted blog posts are filtered out for users.
Pythonian commented 3 months ago

Will it be necessary to include a "url" to the blog post in the response API?

Example: "url": f"/api/v1/blogs/{blog.id}"