arm-core/api/tests/test_goodwill_contract.py

23 lines
935 B
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.

"""Локальный OpenAPI совпадает с четырьмя маршрутами приложения."""
from pathlib import Path
import yaml
from src.app import app
from src.schemas.goodwill import GoodwillRowIn
from src.services.goodwill import validate_decision
def test_contract_matches_application():
contract = yaml.safe_load(
(Path(__file__).resolve().parents[2] / "goodwill/api-contract-goodwill.openapi.yaml").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]
data = GoodwillRowIn(ownership_share="80.1234", include_in_kfo=True, comment="Доля подтверждена")
assert str(validate_decision(data).ownership_share) == "80.1234"