fix(ledger): disjoint unified action schema and refresh req-001 traceability docs

Co-authored-by: genichin <4282227+genichin@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-09-09 13:34:50 +00:00
committed by GitHub
co-authored by genichin
parent e261a41b7f
commit 42297030ca
4 changed files with 26 additions and 21 deletions
+17
View File
@@ -12,10 +12,12 @@ from unittest.mock import patch
import pytest
from fastapi.testclient import TestClient
from pydantic import ValidationError
from app.core.config import Settings, get_settings
from app.domain.models import LedgerEntry, Portfolio, TokenPrincipal
from app.main import create_app
from app.schemas.v1 import LedgerHistoryItem
_PORTFOLIO_ID = "pf-001"
_USER_ID = "user-001"
@@ -987,6 +989,21 @@ def test_unified_ledger_openapi_contains_nullable_amount() -> None:
history_amount_types = {option.get("type") for option in schemas["LedgerHistoryItem"]["properties"]["amount"]["anyOf"]}
assert history_amount_types == {"number", "null"}
assert schemas["DividendLedgerHistoryItem"]["properties"]["amount"]["type"] == "string"
assert "DIVIDEND" not in schemas["LedgerHistoryItem"]["properties"]["action"]["enum"]
assert schemas["DividendLedgerHistoryItem"]["properties"]["action"]["const"] == "DIVIDEND"
def test_unified_ledger_history_item_rejects_dividend_numeric_branch_payload() -> None:
with pytest.raises(ValidationError):
LedgerHistoryItem(
ledger_entry_id=1,
portfolio_id=_PORTFOLIO_ID,
source="manual",
action="DIVIDEND",
recorded_at=datetime.now(UTC),
amount=1.0,
tax_amount=0.0,
)
def test_reversal_rejects_fee_tax_and_missing_target() -> None: