"""Контракт гудвилла в docs (`dev/api-contract-goodwill.openapi.yaml`) совпадает с маршрутами и схемами приложения.""" from decimal import Decimal from pathlib import Path import pytest import yaml from src.app import app from src.schemas.goodwill import GoodwillRowIn from src.services.goodwill import validate_decision CONTRACT = Path(__file__).resolve().parents[3] / "docs/dev/api-contract-goodwill.openapi.yaml" def test_contract_matches_application(): if not CONTRACT.exists(): pytest.skip("нет ../docs: контракт гудвилла не проверен") contract = yaml.safe_load(CONTRACT.read_text()) actual = app.openapi() paths = {key: value for key, value in actual["paths"].items() if "/goodwill" in key} assert contract["paths"] == paths for name, schema in contract["components"]["schemas"].items(): assert schema == actual["components"]["schemas"][name], name def test_share_with_comma(): data = GoodwillRowIn(ownership_share="80,12", include_in_kfo=True, comment="Доля подтверждена") assert validate_decision(data).ownership_share == Decimal("80.12")