feat: 엔트리포인트 및 로깅 설정 완료, 테스트 mock 개선

Made-with: Cursor
This commit is contained in:
21in7
2026-03-01 12:54:21 +09:00
parent 726e9cfd65
commit a90618896d
3 changed files with 54 additions and 11 deletions

View File

@@ -19,19 +19,20 @@ def config():
@pytest.mark.asyncio
async def test_set_leverage(config):
client = BinanceFuturesClient(config)
with patch.object(
client.client,
"futures_change_leverage",
return_value={"leverage": 10},
):
with patch("src.exchange.Client") as MockClient:
mock_binance = MagicMock()
MockClient.return_value = mock_binance
mock_binance.futures_change_leverage.return_value = {"leverage": 10}
client = BinanceFuturesClient(config)
result = await client.set_leverage(10)
assert result is not None
def test_calculate_quantity(config):
client = BinanceFuturesClient(config)
# 잔고 1000 USDT, 리스크 2%, 레버리지 10, 가격 0.5
qty = client.calculate_quantity(balance=1000.0, price=0.5, leverage=10)
# 1000 * 0.02 * 10 / 0.5 = 400
assert qty == pytest.approx(400.0, rel=0.01)
with patch("src.exchange.Client") as MockClient:
MockClient.return_value = MagicMock()
client = BinanceFuturesClient(config)
# 잔고 1000 USDT, 리스크 2%, 레버리지 10, 가격 0.5
qty = client.calculate_quantity(balance=1000.0, price=0.5, leverage=10)
# 1000 * 0.02 * 10 / 0.5 = 400
assert qty == pytest.approx(400.0, rel=0.01)