diff --git a/tests/test_ids.py b/tests/test_ids.py index 27ade3cc6..814c0c7e3 100644 --- a/tests/test_ids.py +++ b/tests/test_ids.py @@ -39,6 +39,15 @@ def test_spot_market_id(): assert url_dict["newClientOrderId"].startswith("x-HNA2TXFJ") +def test_spot_cancel_replace_id(): + with requests_mock.mock() as m: + m.post("https://api.binance.com/api/v3/order/cancelReplace", json={}, status_code=200) + client.cancel_replace_order( + cancelOrderId="orderId", symbol="LTCUSDT", side="BUY", type="MARKET", quantity=0.1 + ) + url_dict = dict(pair.split("=") for pair in m.last_request.text.split("&")) + assert url_dict["newClientOrderId"].startswith("x-HNA2TXFJ") + def test_swap_id(): with requests_mock.mock() as m: m.post("https://fapi.binance.com/fapi/v1/order", json={}, status_code=200) @@ -147,6 +156,28 @@ def handler(url, **kwargs): await clientAsync.close_connection() +@pytest.mark.asyncio() +async def test_spot_cancel_replace_id_async(): + clientAsync = AsyncClient( + api_key="api_key", api_secret="api_secret" + ) # reuse client later + with aioresponses() as m: + + def handler(url, **kwargs): + client_order_id = kwargs["data"][0][1] + assert client_order_id.startswith("x-HNA2TXFJ") + + m.post( + "https://api.binance.com/api/v3/order/cancelReplace", + payload={"id": 1}, + status=200, + callback=handler, + ) + await clientAsync.cancel_replace_order( + orderId="id", symbol="LTCUSDT", side="BUY", type="MARKET", quantity=0.1 + ) + await clientAsync.close_connection() + @pytest.mark.asyncio() async def test_swap_id_async(): clientAsync = AsyncClient(api_key="api_key", api_secret="api_secret")