In Day4, I prepared the development environment and created the basic project structure.
Instead of building a complete test framework immediately, I would started with a small business flow:
Check API → Create Booking → Retrieve Booking
The goal is to confirm that pytest and requests can successfully interact with the Restful Booker API.
Check the API
Before testing any business operation, I used the /ping endpoint to check whether the API was available.
This became the first smoke test:
The test sends a request and checks the returned HTTP status code. It is simple, but it helps separate environment problems from actual test failures.
Create the First Booking
After confirming that the API was available, I created the first booking through:
POST /booking
The request contained basic booking information, including:
The test then checked whether the request succeeded, a new bookingid was generated, and the returned data matched the original request.
The basic process was:Request → Response → Assertion
This became the first positive test:
Retrieve the Booking
Receiving a successful response from POST /booking does not necessarily prove that the data was stored correctly.
Therefore, I used the generated bookingid to retrieve the same booking:
POST /booking
↓
bookingid
↓
GET /booking/{bookingid}
The retrieved booking data should match the data used when creating it.
This introduced another important type of validation:
The test is no longer checking only a single response. It now verifies a small workflow and confirms the state of the system after an operation.
Run the Tests
Finally, I ran the tests with pytest:
pytest
All three tests passed:
3 passed
At this point, the project can:
Now the tests work.