fix: close broker uncertainty audit gaps
This commit is contained in:
@@ -11,7 +11,7 @@ import os
|
||||
import httpx
|
||||
import pytest
|
||||
|
||||
from trex_core.adapters.broker.kis import KISBroker
|
||||
from trex_core.adapters.broker.kis import KISBroker, _balance_http_error_code
|
||||
from trex_core.application.broker_port import (
|
||||
BrokerBalanceError,
|
||||
CancelState,
|
||||
@@ -31,6 +31,41 @@ def test_account_split_and_mock_tr_ids():
|
||||
assert "12345678" not in b.account_scope_hash()
|
||||
|
||||
|
||||
def test_account_scope_hash_separates_endpoint_and_application_identity():
|
||||
mock_a = KISBroker(
|
||||
"12345678-01", app_key="app-a", app_secret="s", base_url=_MOCK_URL
|
||||
)
|
||||
mock_b = KISBroker(
|
||||
"12345678-01", app_key="app-b", app_secret="s", base_url=_MOCK_URL
|
||||
)
|
||||
live_a = KISBroker(
|
||||
"12345678-01",
|
||||
app_key="app-a",
|
||||
app_secret="s",
|
||||
base_url="https://openapi.koreainvestment.com:9443",
|
||||
allow_live=True,
|
||||
)
|
||||
|
||||
assert len({mock_a.account_scope_hash(), mock_b.account_scope_hash(),
|
||||
live_a.account_scope_hash()}) == 3
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("status", "code"),
|
||||
[
|
||||
(400, "broker_rejected"),
|
||||
(401, "authentication_failed"),
|
||||
(403, "authorization_failed"),
|
||||
(422, "broker_rejected"),
|
||||
(429, "transport_failed"),
|
||||
(500, "transport_failed"),
|
||||
(None, "broker_rejected"),
|
||||
],
|
||||
)
|
||||
def test_balance_http_status_classification(status, code):
|
||||
assert _balance_http_error_code(status) == code
|
||||
|
||||
|
||||
def test_live_base_url_requires_allow_live():
|
||||
with pytest.raises(RuntimeError):
|
||||
KISBroker(
|
||||
|
||||
Reference in New Issue
Block a user