Skip to content

vadymdrozd/backend_framework_example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Human API Autotests

API autotest suite built with pytest for validating Human platform functionality across different user roles: admin, teacher, pupil, parent, and unauthorized access scenarios.

Overview

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 pytest fixtures for config, API clients, and role tokens
  • Allure reporting support

Tech Stack

  • Python 3
  • pytest
  • requests
  • python-dotenv
  • SQLAlchemy
  • PyMySQL
  • Allure

Installation

1. Create a virtual environment

Windows

python -m venv .venv
.venv\Scripts\activate

Linux / macOS

python -m venv .venv
source .venv/bin/activate

2. Install dependencies

pip install -r requirements.txt

Environment Configuration

Before 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=

Variable descriptions

  • HUM_BASE_URL - base URL for the main API
  • HUM_FILES_URL - base URL for file-related API requests
  • HUM_ADMIN / HUM_ADMIN_PASS - admin credentials
  • HUM_TEACHER / HUM_TEACHER_PASS - teacher credentials
  • HUM_PUPIL / HUM_PUPIL_PASS - pupil credentials
  • HUM_PARENT / HUM_PARENT_PASS - parent credentials

Project Structure

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

Configuration and Fixtures

Global fixtures

Defined in conftest.py:

  • config - singleton-based Config object
  • human_api - ApiClient initialized with HUM_BASE_URL
  • human_files_api - ApiClient initialized with HUM_FILES_URL

Role token fixtures

Defined in tests/conftest.py:

  • admin_token
  • teacher_token
  • parent_token
  • pupil_token

Each token is created once per test session using authenticate(...) and invalidated after the session with logout(...).

Running Tests

Run all tests

pytest

Run a specific test file

pytest tests/unauthorized/test_unathorized.py

Run a specific directory

pytest tests/navigation/

Run tests by marker

Available markers are defined in pytest.ini, including:

  • home_task
  • assessments
  • navigation
  • course_content
  • journal_teacher
  • prod

Example:

pytest -m navigation

Allure Reporting

Generate Allure results

pytest --alluredir=allure-results

Open the report locally

allure serve allure-results

If Allure CLI is not installed, install it separately before using the command above.

Implementation Notes

  • Base URLs are loaded from .env
  • Authentication is performed in utils/auth_helper.py
  • HTTP requests are wrapped by ApiClient in utils/api_client.py
  • Request URLs are attached to Allure via allure.dynamic.link(...)
  • Shared configuration is exposed through the singleton-based Config

Useful Notes

  • Make sure the target test environment is available before starting a run
  • Verify that credentials in .env are 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

Quick Start

python -m venv .venv
pip install -r requirements.txt
pytest

Notes

This 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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages