feat: exchange client accepts explicit symbol parameter, removes config.symbol dependency

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
21in7
2026-03-05 23:07:44 +09:00
parent 9318fb887e
commit 2e09f5340a
2 changed files with 26 additions and 10 deletions

View File

@@ -22,6 +22,7 @@ def client():
config.leverage = 10
c = BinanceFuturesClient.__new__(BinanceFuturesClient)
c.config = config
c.symbol = config.symbol
return c
@@ -36,10 +37,24 @@ def exchange():
config = Config()
c = BinanceFuturesClient.__new__(BinanceFuturesClient)
c.config = config
c.symbol = config.symbol
c.client = MagicMock()
return c
def test_exchange_uses_own_symbol():
"""Exchange 클라이언트가 config.symbol 대신 생성자의 symbol을 사용한다."""
os.environ.update({
"BINANCE_API_KEY": "test_key",
"BINANCE_API_SECRET": "test_secret",
"SYMBOL": "XRPUSDT",
})
config = Config()
with patch("src.exchange.Client"):
client = BinanceFuturesClient(config, symbol="TRXUSDT")
assert client.symbol == "TRXUSDT"
@pytest.mark.asyncio
async def test_set_leverage(config):
with patch("src.exchange.Client") as MockClient: