23 lines
935 B
Python
23 lines
935 B
Python
"""Локальный 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"
|