fix: restore manual confirm_duplicate compatibility and precision safeguards
Co-authored-by: genichin <4282227+genichin@users.noreply.github.com>
This commit is contained in:
co-authored by
genichin
parent
a71c91f6ef
commit
aa40c7fdff
@@ -558,6 +558,37 @@ def test_dividend_duplicate_requires_confirmation() -> None:
|
||||
assert confirmed.status_code == 201
|
||||
|
||||
|
||||
def test_confirm_duplicate_false_is_accepted_for_non_dividend_actions() -> None:
|
||||
repo = _FakeRepo(_portfolio())
|
||||
client = _make_client(repo)
|
||||
|
||||
invest = client.post(
|
||||
f"/v1/portfolios/{_PORTFOLIO_ID}/ledger/manual",
|
||||
json={"action": "INVEST", "amount": 100, "confirm_duplicate": False},
|
||||
headers=_auth(),
|
||||
)
|
||||
assert invest.status_code == 201
|
||||
|
||||
buy = client.post(
|
||||
f"/v1/portfolios/{_PORTFOLIO_ID}/ledger/manual",
|
||||
json={"action": "BUY", "quantity": 1, "price": 10, "confirm_duplicate": False},
|
||||
headers=_auth(),
|
||||
)
|
||||
assert buy.status_code == 201
|
||||
|
||||
|
||||
def test_confirm_duplicate_true_is_rejected_for_non_dividend_actions() -> None:
|
||||
repo = _FakeRepo(_portfolio())
|
||||
client = _make_client(repo)
|
||||
|
||||
invest = client.post(
|
||||
f"/v1/portfolios/{_PORTFOLIO_ID}/ledger/manual",
|
||||
json={"action": "INVEST", "amount": 100, "confirm_duplicate": True},
|
||||
headers=_auth(),
|
||||
)
|
||||
assert invest.status_code == 422
|
||||
|
||||
|
||||
def test_dividend_reversal_decreases_profit_buffer() -> None:
|
||||
repo = _FakeRepo(_portfolio(buffer=200))
|
||||
client = _make_client(repo)
|
||||
|
||||
Reference in New Issue
Block a user