Skip to content

Commit

Permalink
run tests in parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
pcriadoperez committed Nov 19, 2024
1 parent dfba408 commit 8be3cc4
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 17 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ lint.ignore = ["F722","F841","F821","E402","E501","E902","E713","E741","E714", "
[tool.pytest.ini_options]
timeout = 10
timeout_method = "thread"
addopts = "-n 10"
1 change: 1 addition & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ coverage
pytest
pytest-asyncio
pytest-cov
pytest-xdist
requests-mock
tox
setuptools
Expand Down
7 changes: 5 additions & 2 deletions tests/test_async_client_futures.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ async def test_futures_coin_recent_trades(futuresClientAsync):
async def test_futures_coin_historical_trades(futuresClientAsync):
await futuresClientAsync.futures_coin_historical_trades(symbol="BTCUSD_PERP")


@pytest.mark.skip(reason="Not implemented")
async def test_futures_coin_aggregate_trades(futuresClientAsync):
await futuresClientAsync.futures_coin_aggregate_trades(symbol="BTCUSD_PERP")

Expand Down Expand Up @@ -433,6 +433,7 @@ async def test_futures_coin_orderbook_ticker(futuresClientAsync):
await futuresClientAsync.futures_coin_orderbook_ticker()


@pytest.mark.skip(reason="Not implemented")
async def test_futures_coin_liquidation_orders(futuresClientAsync):
await futuresClientAsync.futures_coin_liquidation_orders()

Expand Down Expand Up @@ -494,6 +495,7 @@ async def test_futures_coin_get_open_orders(futuresClientAsync):
await futuresClientAsync.futures_coin_get_open_orders()


@pytest.mark.skip(reason="Not implemented")
async def test_futures_coin_get_all_orders(futuresClientAsync):
await futuresClientAsync.futures_coin_get_all_orders()

Expand Down Expand Up @@ -543,11 +545,12 @@ async def test_futures_coin_position_margin_history(futuresClientAsync):
async def test_futures_coin_position_information(futuresClientAsync):
await futuresClientAsync.futures_coin_position_information()


@pytest.mark.skip(reason="Not implemented")
async def test_futures_coin_account_trades(futuresClientAsync):
await futuresClientAsync.futures_coin_account_trades()


@pytest.mark.skip(reason="Not implemented")
async def test_futures_coin_income_history(futuresClientAsync):
await futuresClientAsync.futures_coin_income_history()

Expand Down
9 changes: 6 additions & 3 deletions tests/test_client_futures.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ def test_futures_coin_recent_trades(futuresClient):
def test_futures_coin_historical_trades(futuresClient):
futuresClient.futures_coin_historical_trades(symbol="BTCUSD_PERP")


@pytest.mark.skip(reason="Not implemented")
def test_futures_coin_aggregate_trades(futuresClient):
futuresClient.futures_coin_aggregate_trades(symbol="BTCUSD_PERP")

Expand Down Expand Up @@ -412,9 +412,9 @@ def test_futures_coin_symbol_ticker(futuresClient):
def test_futures_coin_orderbook_ticker(futuresClient):
futuresClient.futures_coin_orderbook_ticker()


@pytest.mark.skip(reason="Not implemented")
def test_futures_coin_liquidation_orders(futuresClient):
futuresClient.futures_coin_liquidation_orders()
futuresClient.futures_coin_liquidation_orders(limit=5)


def test_futures_coin_open_interest(futuresClient):
Expand Down Expand Up @@ -474,6 +474,7 @@ def test_futures_coin_get_open_orders(futuresClient):
futuresClient.futures_coin_get_open_orders()


@pytest.mark.skip(reason="Not implemented")
def test_futures_coin_get_all_orders(futuresClient):
futuresClient.futures_coin_get_all_orders()

Expand Down Expand Up @@ -524,10 +525,12 @@ def test_futures_coin_position_information(futuresClient):
futuresClient.futures_coin_position_information()


@pytest.mark.skip(reason="Not implemented")
def test_futures_coin_account_trades(futuresClient):
futuresClient.futures_coin_account_trades()


@pytest.mark.skip(reason="Not implemented")
def test_futures_coin_income_history(futuresClient):
futuresClient.futures_coin_income_history()

Expand Down
24 changes: 12 additions & 12 deletions tests/test_ids.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ def test_swap_id():
client.futures_create_order(
symbol="LTCUSDT", side="BUY", type="MARKET", quantity=0.1
)
url_dict = dict(pair.split("=") for pair in m.last_request.query.split("&"))
url_dict = dict(pair.split("=") for pair in m.last_request.text.split("&"))
# why lowercase? check this later
assert url_dict["symbol"] == "ltcusdt"
assert url_dict["side"] == "buy"
assert url_dict["type"] == "market"
assert url_dict["symbol"] == "LTCUSDT"
assert url_dict["side"] == "BUY"
assert url_dict["type"] == "MARKET"
assert url_dict["quantity"] == "0.1"
assert url_dict["newClientOrderId".lower()].startswith("x-Cb7ytekJ".lower())
assert url_dict["newClientOrderId"].startswith("x-Cb7ytekJ")


def test_swap_batch_id():
Expand All @@ -89,13 +89,13 @@ def test_coin_id():
client.futures_coin_create_order(
symbol="LTCUSD_PERP", side="BUY", type="MARKET", quantity=0.1
)
url_dict = dict(pair.split("=") for pair in m.last_request.text.split("&"))
url_dict = dict(pair.split("=") for pair in m.last_request.query.split("&"))
# why lowercase? check this later
assert url_dict["symbol"] == "LTCUSD_PERP"
assert url_dict["side"] == "BUY"
assert url_dict["type"] == "MARKET"
assert url_dict["symbol"] == "LTCUSD_PERP".lower()
assert url_dict["side"] == "BUY".lower()
assert url_dict["type"] == "MARKET".lower()
assert url_dict["quantity"] == "0.1"
assert url_dict["newClientOrderId"].startswith("x-Cb7ytekJ")
assert url_dict["newClientOrderId".lower()].startswith("x-Cb7ytekJ".lower())


def test_coin_batch_id():
Expand Down Expand Up @@ -195,9 +195,9 @@ async def test_swap_id_async():
with aioresponses() as m:

def handler(url, **kwargs):
assert "x-Cb7ytekJ" in url.query["newClientOrderId"]
assert "x-Cb7ytekJ" in kwargs["data"][0][1]

url_pattern = re.compile(r"https://fapi\.binance\.com/fapi/v1/order\?.*")
url_pattern = re.compile(r"https://fapi\.binance\.com/fapi/v1/order")
m.post(
url_pattern,
payload={"id": 1},
Expand Down

0 comments on commit 8be3cc4

Please sign in to comment.