API test suite for the TestMe API using Playwright and pytest.
# Install dependencies
make install
# Run tests in headless mode with console output
make test
# Run tests with HTML report
make test-html- Current version: 0.1.0
- See
RELEASE.mdfor detailed release notes.
pytest– testing frameworkplaywright/pytest-playwright– HTTP client (APIRequestContext) and pytest integrationpytest-xdist– parallel test executionpytest-html– HTML reports with embedded logspydantic,pydantic-settings– data models and configurationfaker– test data generationpython-dotenv– environment configurationuv– Python package manager
ruff– linter and formatter (replaces flake8 + black + isort)
-
api/base_client.py– low-level HTTP client using PlaywrightAPIRequestContext(GET/POST/PUT/PATCH/DELETE)auth_client.py– authentication endpoints (login, logout, CSRF token handling)test_cases_client.py– test case CRUD and status endpointsstats_client.py– statistics endpoints
-
models/test_case.py– Pydantic models for tests and statusesstats.py– statistics response modelerror.py– error response models
-
data/factories.py– Faker-basedTestDataFactoryfor generating test data
-
config/settings.py– PydanticSettingswith env-based configuration (.env)
-
utils/assertions.py– response assertion helpers (status codes, JSON keys, partial match)logger.py– dual logger (file logs + pytest-html logs for HTTP requests/responses)
tests/test_auth.py– authentication and CSRF token teststests/test_test_cases.py– CRUD + status + workflow tests for test casestests/test_stats.py– statistics aggregation teststests/test_lists.py– listing and pagination teststests/conftest.py– PlaywrightAPIRequestContext, authenticated clients, shared fixtures
Makefile– unified entrypoint for install / test / lint / dockerpyproject.toml– dependencies and tool configurationpytest.ini– pytest defaults and markersreports/– HTML reportslogs/– HTTP request/response logs (log_*.log)
- Each logical area of the API has its own client:
AuthClient– login/logout, CSRF token extraction and storageTestCasesClient– create/read/update/delete, status change, parsing helpersStatsClient– retrieving statistics and parsing intoStatisticsmodel
- Common HTTP logic (headers, CSRF, logging) is implemented once in
BaseClient.
- Requests:
CreateTestRequest,UpdateTestRequest,TestStatusRequest
- Responses:
CreateTestResponse,SetTestStatusResponse,TestCase,Statistics,ErrorResponse
- Validation is done on client side before sending requests where appropriate.
- Session-level
APIRequestContextfrom Playwright for all tests. - Function-level fixtures:
auth_client,test_cases_client,stats_clientauthenticated_client,authenticated_test_client,authenticated_stats_clientcreated_test_id– creates and cleans up a test case around a test.
- Tests are organized by markers:
smoke,regression,auth,tests,stats,positive,negative.
- Generated by
pytest-htmlvia:
make test-html # creates reports/test_report.htmlreports/test_report.htmlincludes:- test execution summary and statistics
- environment details (Python, platform, plugins)
- per-test logs from
Logger(REQUEST/RESPONSE blocks)
Generated HTML report (reports/test_report.html) provides a comprehensive view of test execution:
The report includes:
- overall execution summary for all TestMe API suites (auth, tests, lists, stats)
- environment details (Python version, OS, pytest and plugin versions, Faker/Playwright metadata)
- per-test status with duration and markers (smoke, regression, positive, negative, etc.)
- detailed logs for each test with timestamps and captured Playwright
APIRequestContextcalls - HTTP request/response details (method, URL, status, headers, bodies) for TestMe endpoints
- JSON-formatted request/response bodies for API calls that return JSON
- expandable test details to quickly inspect failed or flaky API scenarios
- All HTTP requests/responses are logged into
logs/log_*.logbyutils.logger.Logger. - Example entry:
-----
Test: tests/test_auth.py::TestAuthenticationPositive::test_login_with_valid_credentials (call)
Time: 2025-12-02 10:32:29.334860
Request method: POST
Request URL: http://127.0.0.1:8000/api/auth/login
Request headers: {
"Content-Type": "application/json",
"Accept": "application/json",
"Connection": "keep-alive",
"X-CSRFToken": "ZfwMBBA1JGWiFC7bLlk52d5iRJT27Bu0bWMVmBYF5oBcG1sViZzwRFhMN8Gb3DxQ"
}
Request body: {
"username": "alice",
"password": "Qamania123"
}
Response code: 200
Response text:
Response headers: {
"date": "Tue, 02 Dec 2025 08:32:29 GMT",
"server": "WSGIServer/0.2 CPython/3.11.14",
"content-type": "text/html; charset=utf-8",
"content-length": "0",
"set-cookie": "csrftoken=...; sessionid=..."
}
Each block contains:
- clear test identifier and phase (
setup/call/teardown) - precise timestamp when the HTTP interaction happened
- full request details: HTTP method, URL, headers, and serialized body
- full response details: status code, headers, and raw/JSON body
- visual separators (
-----) between interactions for easier scanning in large logs
Configuration is loaded from environment variables using pydantic-settings (config/settings.py).
# API Configuration
API_BASE_URL=http://127.0.0.1:8000
API_TIMEOUT=30000
# Test User Credentials
TEST_USERNAME=alice
TEST_PASSWORD=Qamania123
# Test Configuration
HEADLESS=true
PARALLEL_WORKERS=4
LOG_LEVEL=INFOKey options:
API_BASE_URL– base URL for TestMe APIAPI_TIMEOUT– request timeout in msTEST_USERNAME/TEST_PASSWORD– credentials for positive auth testsHEADLESS– controls Playwright/headless modePARALLEL_WORKERS– used forpytest-xdist(-n auto)LOG_LEVEL– logger level (DEBUG,INFO, etc.)
make test # run full test suite
make test-html # run tests with HTML report
make test-smoke # smoke subset
make test-auth # auth tests
make test-tests # test case management
make test-stats # statistics
make test-lists # list/pagination
make test-regression # regression suite
make test-positive # positive tests only
make test-negative # negative tests only
make test-parallel # run tests in parallelmake lint # run Ruff checks
make fix # auto-fix issues with Ruff
make format # format code
make clean # remove caches, reports and logs
make help # list all make targets- Authentication
- login/logout happy path
- invalid credentials and edge cases
- CSRF token retrieval and reuse
- Test Cases
- create / read / update / delete
- status changes (PASS/FAIL)
- workflows (full CRUD + status)
- authorization and error handling
- Lists and Pagination
- list endpoints with/without pagination
- page/size combinations and boundaries
- Statistics
- structure validation
- model parsing and consistency checks
make install # sync dependencies with uv
make test # run test suite
make test-html # run tests with HTML report
make lint # run lint checks
make format # format code
make clean # remove caches, reports, logs
make docker-build # build Docker image
make docker-test # run tests inside Docker
make help # show all commandsAPI Documentation: https://documenter.getpostman.com/view/2037649/UV5TEe6x
TestMe App Repository: https://github.com/Ypurek/TestMe-TCM
Release Notes: See RELEASE.md for detailed version history and changes.
