API autotest suite built with pytest for validating Human platform functionality across different user roles: admin, teacher, pupil, parent, and unauthorized access scenarios.
This repository contains:
- API tests grouped by business modules in
tests/ - central configuration for users, endpoints, methods, and database helpers in
core/config/ - reusable HTTP client and authentication helpers in
utils/ - shared
pytestfixtures for config, API clients, and role tokens - Allure reporting support
- Python 3
- pytest
- requests
- python-dotenv
- SQLAlchemy
- PyMySQL
- Allure
python -m venv .venv
.venv\Scripts\activatepython -m venv .venv
source .venv/bin/activatepip install -r requirements.txtBefore running the tests, create a .env file based on .env.example and fill in the required environment variables.
The current code directly uses the following variables:
HUM_BASE_URL=
HUM_FILES_URL=
HUM_ADMIN=
HUM_ADMIN_PASS=
HUM_TEACHER=
HUM_TEACHER_PASS=
HUM_PUPIL=
HUM_PUPIL_PASS=
HUM_PARENT=
HUM_PARENT_PASS=HUM_BASE_URL- base URL for the main APIHUM_FILES_URL- base URL for file-related API requestsHUM_ADMIN/HUM_ADMIN_PASS- admin credentialsHUM_TEACHER/HUM_TEACHER_PASS- teacher credentialsHUM_PUPIL/HUM_PUPIL_PASS- pupil credentialsHUM_PARENT/HUM_PARENT_PASS- parent credentials
core/
config/ Configuration for users, endpoints, methods, and DB helpers
utils/ API client, logging, authentication helpers
tests/ Test suites by module and role
conftest.py Global pytest fixtures
pytest.ini Pytest markers
allure-results/ Allure raw test results
Defined in conftest.py:
config- singleton-basedConfigobjecthuman_api-ApiClientinitialized withHUM_BASE_URLhuman_files_api-ApiClientinitialized withHUM_FILES_URL
Defined in tests/conftest.py:
admin_tokenteacher_tokenparent_tokenpupil_token
Each token is created once per test session using authenticate(...) and invalidated after the session with logout(...).
pytestpytest tests/unauthorized/test_unathorized.pypytest tests/navigation/Available markers are defined in pytest.ini, including:
home_taskassessmentsnavigationcourse_contentjournal_teacherprod
Example:
pytest -m navigationpytest --alluredir=allure-resultsallure serve allure-resultsIf Allure CLI is not installed, install it separately before using the command above.
- Base URLs are loaded from
.env - Authentication is performed in
utils/auth_helper.py - HTTP requests are wrapped by
ApiClientinutils/api_client.py - Request URLs are attached to Allure via
allure.dynamic.link(...) - Shared configuration is exposed through the singleton-based
Config
- Make sure the target test environment is available before starting a run
- Verify that credentials in
.envare valid - For unstable environments, it is safer to run a single directory or file first
allure-results/may contain artifacts from previous runs and can be cleaned before a new execution
python -m venv .venv
pip install -r requirements.txt
pytestThis README reflects the current project state based on the provided code. If .env.example contains additional variables for endpoints or database access, they should also be configured for the target environment.