Skip to content

Repository files navigation

Restful Booker test framework

Python test automation framework for Restful Booker Platform.

Stack

  • Python 3.13+
  • uv
  • pytest
  • httpx
  • DeepDiff
  • Allure Report

Setup

uv sync
uv run pytest tests/unit

Configuration

Configuration is read from environment variables and represented by frozen dataclasses.

Copy the example and keep credentials in the local .env file:

cp .env.example .env

.env is excluded from Git.

Integration tests

Start the Restful Booker backend services:

docker compose up -d
docker compose ps

Run the integration tests:

uv run pytest tests/integration

Service-based test selection

Integration tests are marked with every service they require. This includes both the service under test and services used for authentication or test data setup. For example, the Booking tests have booking, room, and auth markers.

Run the tests affected by a service change:

uv run pytest -m auth
uv run pytest -m booking
uv run pytest -m message
uv run pytest -m room

As a result, -m room runs both Room and Booking tests, while -m auth also includes tests that require an authentication token.

Test results are appended to allure-results, so separate test runs can be combined into one report. To discard previous results before a new full run, use:

uv run pytest --clean-alluredir

With the Allure CLI installed, open the report using:

allure serve allure-results

Stop the services when they are no longer needed:

docker compose down

Quality checks

uv run ruff check .
uv run ruff format --check .

Continuous integration

The Quality checks workflow runs Ruff and unit tests without starting backend services.

The Integration tests workflow starts the backend with Docker Compose, waits for every service, and runs the full integration suite. A manual workflow run can be limited to the auth, booking, message, or room dependency marker. Raw Allure results are retained as a workflow artifact for 14 days.

About

pytest project example

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages