"""Общие фикстуры контрактных тестов.""" from __future__ import annotations from collections.abc import Iterator from typing import Any import pytest from fastapi import FastAPI from fastapi.testclient import TestClient from awg_api.app import create_app from awg_api.contract import load_spec from awg_api.state import MockState TEST_TOKEN = "test-token-contract" @pytest.fixture(scope="session") def spec() -> dict[str, Any]: """Спецификация контракта (docs/openapi.yaml).""" return load_spec() @pytest.fixture def state() -> MockState: return MockState() @pytest.fixture def app(state: MockState) -> FastAPI: return create_app(state=state, token=TEST_TOKEN) @pytest.fixture def client(app: FastAPI) -> Iterator[TestClient]: with TestClient(app) as test_client: yield test_client @pytest.fixture def auth_headers() -> dict[str, str]: return {"Authorization": f"Bearer {TEST_TOKEN}"} @pytest.fixture def token() -> str: return TEST_TOKEN