From 5480c3b2b7430bd5a4c71a89ddd43026c10fa0bd Mon Sep 17 00:00:00 2001 From: Morty Space Date: Mon, 30 May 2022 18:59:33 +0200 Subject: [PATCH] test: fix retry with canceled orders --- .github/workflows/{test.yml => cicd.yml} | 2 +- tests/test_private.py | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) rename .github/workflows/{test.yml => cicd.yml} (99%) diff --git a/.github/workflows/test.yml b/.github/workflows/cicd.yml similarity index 99% rename from .github/workflows/test.yml rename to .github/workflows/cicd.yml index e8ceb62..19d1dc3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/cicd.yml @@ -1,5 +1,5 @@ --- -name: Test and Release +name: CI / CD on: schedule: - cron: "0 */4 * * *" diff --git a/tests/test_private.py b/tests/test_private.py index 31109f4..3ce3792 100644 --- a/tests/test_private.py +++ b/tests/test_private.py @@ -18,7 +18,7 @@ def retry(times: int): def decorator(f): @functools.wraps(f) - async def wrapper(*args, **kwargs): + async def wrapper(account: cro.Account, *args, **kwargs): nonlocal times while True: try: @@ -27,6 +27,8 @@ def retry(times: int): times -= 1 if not times: raise exc + while account.get_open_orders(cro.pairs.CRO_USDT): + await account.cancel_open_orders(cro.pairs.CRO_USDT) return wrapper @@ -55,7 +57,7 @@ async def test_account_get_balance(account: cro.Account): @pytest.mark.asyncio async def test_deposit_withdrawal_history( - exchange: cro.Exchange, account: cro.Account + account: cro.Account, exchange: cro.Exchange ): transactions = await account.get_withdrawal_history(cro.coins.CRO) assert transactions @@ -86,7 +88,8 @@ async def test_deposit_withdrawal_history( @pytest.mark.asyncio @retry(5) async def test_no_duplicate_mass_limit_orders( - exchange: cro.Exchange, account: cro.Account + account: cro.Account, + exchange: cro.Exchange, ): buy_price = round(await exchange.get_price(cro.pairs.CRO_USDT) / 2, 4) orders_count = 50