hngprojects / hng_boilerplate_python_fastapi_web

Apache License 2.0
153 stars 136 forks source link

[FEAT] Implement API to Retrieve Latest Blog Posts with Pagination #120

Open oluwaschunne opened 3 months ago

oluwaschunne commented 3 months ago

Description

Acceptance Criteria

Purpose

Requirements

Expected Outcome

Endpoints

[GET] /api/v1/blogs/latest

Description:

Query Parameters:

Success Response:

Error Response:

Invalid Method Response:

Bad Request Response:

Testing

Test Scenarios

  1. Successful Retrieval of Paginated Latest Blog Posts

    • Ensure that the endpoint successfully retrieves a paginated list of the latest 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.
  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.
    • Confirm that the response body contains 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.

    see below link to the approved issue hngprojects/hng_boilerplate_nestjs/issues/134

oluwaschunne commented 3 months ago

slack id: oluwaschunne