Skip to main content

🛰️ SputnikQA — Test Automation Framework

PyPI version Python versions License

SputnikQA — фреймворк для автотестов на Python. Внутри два booster'а с общими принципами:

  • REST API — HTTP-клиент с middleware-пайплайном, декларативные API-секции (по аналогии с Page Object) и валидация ответов через pydantic-модели.
  • Web UI — единый интерфейс над Playwright и Selenium: страницы, элементы, списки, композитные виджеты. Синхронный и асинхронный варианты.

Сверху — интеграция с Allure и генератор API-клиента из OpenAPI 3.x.

Установка

pip install sputnikqa

Необязательные зависимости ставятся экстрами:

pip install sputnikqa[httpx]        # HTTP-транспорт на httpx
pip install sputnikqa[requests]     # HTTP-транспорт на requests
pip install sputnikqa[playwright]   # Web UI на Playwright
pip install sputnikqa[selenium]     # Web UI на Selenium
pip install sputnikqa[allure]       # Allure-отчёты

# типичный набор для API+UI проекта
pip install sputnikqa[allure,httpx,playwright]

Python 3.13+.

Пример: REST API

Модель ответа и секция API — по аналогии с Page Object:

from sputnikqa.boosters.restapi.clients import ApiClient
from sputnikqa.boosters.restapi.response_models import JsonResponse
from sputnikqa.boosters.restapi.sections import BaseApiSection
from sputnikqa.boosters.restapi.transports import HttpxTransport


class Pet(JsonResponse):
    id: int | None = None
    name: str
    status: str


class PetSection(BaseApiSection):
    base_url = "https://petstore.swagger.io/v2"

    def get_pet(self, pet_id: int) -> Pet:
        response = self.client.get(self.url_join(f"/pet/{pet_id}"))
        return (
            self.validator(response)
            .validate_status(200)
            .validate_response_model({200: Pet})
            .get_validated_model()
        )

В тесте:

def test_get_pet():
    section = PetSection(ApiClient(HttpxTransport()))
    pet = section.get_pet(1)

    assert pet.name == "doggie"

validate_status() проверяет статус-код, validate_response_model() парсит и валидирует тело pydantic-моделью, get_validated_model() возвращает готовый объект. Любое несовпадение — понятная ошибка с телом ответа, а не загадочный KeyError где-то в тесте.

Пример: Web UI

from sputnikqa.boosters.web_ui.locators import Locator, LocatorStrategy
from sputnikqa.boosters.web_ui.sync_api import (
    BasePage,
    Element,
    create_browser,
    BrowserContext,
)


class LoginPage(BasePage):
    def __init__(self):
        self.username = Element(Locator("#username", LocatorStrategy.CSS))
        self.password = Element(Locator("#password", LocatorStrategy.CSS))
        self.submit = Element(Locator("//button[@type='submit']"))


browser = create_browser("playwright")
with BrowserContext.use_browser(browser):
    browser.open_browser(headless=True)
    browser.navigate_to("https://example.com/login")

    page = LoginPage()
    page.username.fill("admin")
    page.password.fill("secret")
    page.submit.click()

Локаторы ленивые: элемент ищется в момент действия. При ошибке автоматически делается скриншот. Код страницы не меняется при смене бэкенда — create_browser("selenium") даёт тот же интерфейс.

Документация

Документ О чём
REST API booster клиенты, транспорты, middleware, секции, валидация, билдеры
Web UI booster браузеры, страницы, элементы, локаторы, ожидания
Генерация API-клиента из OpenAPI CLI-тулза sputnikqa-openapi
Интеграция с Allure шаги, аттачи запросов, скриншоты
Логирование настройка через стандартный logging
Расширение фреймворка свой транспорт, middleware, валидатор

Лицензия

MIT. Подробности — в LICENSE.


📌 PyPI: https://pypi.org/project/sputnikqa/ 📌 GitVerse: https://gitverse.ru/crenom/SputnikQA

Metadata

Release files for sputnikqa 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sputnikqa 0.1.1
File Size Uploaded Provenance Actions
sputnikqa-0.1.1.tar.gz 82.1 kB Without provenance Details for sputnikqa-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sputnikqa 0.1.1
File Interpreter ABI Platform Actions
sputnikqa-0.1.1-py3-none-any.whl Python 3 none any Details for sputnikqa-0.1.1-py3-none-any.whl

Total release size: 218.3 kB

Release files / sputnikqa-0.1.1.tar.gz

Download URL sputnikqa-0.1.1.tar.gz
Size 82.1 kB
Tags Source
SHA-256 checksum
How to use checksums
25e4b813bfb2fb9f7c4a523c1ac6e0e654229e6e69919cdf4a7d2a694c12fd02
BLAKE2b-256 checksum
How to use checksums
d4918f1e84f2223d73a7d6d023b909dc0cca1bd9f2ec877159bf8d6952609186
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.5.1 CPython/3.13.17 Linux/5.15.0-144-generic

Release files / sputnikqa-0.1.1-py3-none-any.whl

Download URL sputnikqa-0.1.1-py3-none-any.whl
Size 136.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6b2f6185f0b6cc80842e320a615619fe1b31f8dfbcfcf6c49c7ab38d9bd93dd8
BLAKE2b-256 checksum
How to use checksums
150288ad7e9881ab41a07eb32bb732fd2e96dfdd13b618584e22a676f5008ecb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.5.1 CPython/3.13.17 Linux/5.15.0-144-generic

Security for sputnikqa 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page