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:
co-authored by
genichin
parent
e261a41b7f
commit
42297030ca
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user