arm-core/api/tests/test_goodwill_contract.py
Andrey Epifancev 3bfcc2e2aa Гудвилл: контракт в docs, README, OpenSpec под ревью
Тест контракта читает ../docs/dev/api-contract-goodwill.openapi.yaml (без docs — skip);
README: раздел гудвилла и коды INVALID_SHARE/DUPLICATE_ROW/MONEY_OUT_OF_RANGE;
OpenSpec goodwill-table: пакетное сохранение, доля два знака, итоги по ГО и УК,
единицы, Decisions made without discussion R-1…R-6.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 18:41:20 +04:00

30 lines
1.2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""Контракт гудвилла в 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")