|
1 | 1 | import asyncio |
2 | 2 | import pytest |
| 3 | +import sys |
3 | 4 |
|
4 | 5 | from binance.exceptions import BinanceAPIException, BinanceWebsocketUnableToConnect |
5 | 6 | from .test_get_order_book import assert_ob |
@@ -52,7 +53,10 @@ async def test_ws_futures_get_order_book_ticker(futuresClientAsync): |
52 | 53 |
|
53 | 54 |
|
54 | 55 | @pytest.mark.asyncio() |
55 | | -async def test_ws_futures_create_get_edit_cancel_order(futuresClientAsync): |
| 56 | +async def test_ws_futures_create_get_edit_cancel_order_with_orjson(futuresClientAsync): |
| 57 | + if 'orjson' not in sys.modules: |
| 58 | + raise ImportError("orjson is not available") |
| 59 | + |
56 | 60 | ticker = await futuresClientAsync.ws_futures_get_order_book_ticker(symbol="LTCUSDT") |
57 | 61 | positions = await futuresClientAsync.ws_futures_v2_account_position( |
58 | 62 | symbol="LTCUSDT" |
@@ -83,6 +87,39 @@ async def test_ws_futures_create_get_edit_cancel_order(futuresClientAsync): |
83 | 87 | orderid=order["orderId"], symbol=order["symbol"] |
84 | 88 | ) |
85 | 89 |
|
| 90 | +@pytest.mark.asyncio() |
| 91 | +async def test_ws_futures_create_get_edit_cancel_order_without_orjson(futuresClientAsync): |
| 92 | + with patch.dict('sys.modules', {'orjson': None}): |
| 93 | + ticker = await futuresClientAsync.ws_futures_get_order_book_ticker(symbol="LTCUSDT") |
| 94 | + positions = await futuresClientAsync.ws_futures_v2_account_position( |
| 95 | + symbol="LTCUSDT" |
| 96 | + ) |
| 97 | + order = await futuresClientAsync.ws_futures_create_order( |
| 98 | + symbol=ticker["symbol"], |
| 99 | + side="BUY", |
| 100 | + positionSide=positions[0]["positionSide"], |
| 101 | + type="LIMIT", |
| 102 | + timeInForce="GTC", |
| 103 | + quantity=0.1, |
| 104 | + price=str(float(ticker["bidPrice"]) - 2), |
| 105 | + ) |
| 106 | + assert_contract_order(futuresClientAsync, order) |
| 107 | + order = await futuresClientAsync.ws_futures_edit_order( |
| 108 | + orderid=order["orderId"], |
| 109 | + symbol=order["symbol"], |
| 110 | + quantity=0.11, |
| 111 | + side=order["side"], |
| 112 | + price=order["price"], |
| 113 | + ) |
| 114 | + assert_contract_order(futuresClientAsync, order) |
| 115 | + order = await futuresClientAsync.ws_futures_get_order( |
| 116 | + symbol="LTCUSDT", orderid=order["orderId"] |
| 117 | + ) |
| 118 | + assert_contract_order(futuresClientAsync, order) |
| 119 | + order = await futuresClientAsync.ws_futures_cancel_order( |
| 120 | + orderid=order["orderId"], symbol=order["symbol"] |
| 121 | + ) |
| 122 | + |
86 | 123 |
|
87 | 124 | @pytest.mark.asyncio() |
88 | 125 | async def test_ws_futures_v2_account_position(futuresClientAsync): |
|
0 commit comments