diff --git a/v4-client-py-v2/tests/conftest.py b/v4-client-py-v2/tests/conftest.py index d18455bd..1922a6d0 100644 --- a/v4-client-py-v2/tests/conftest.py +++ b/v4-client-py-v2/tests/conftest.py @@ -103,7 +103,7 @@ async def wallet(node_client, private_key, test_address): return await get_wallet(node_client, private_key, test_address) -def retry_on_forbidden(max_retries=3, delay=1): +def retry_on_forbidden(max_retries=3, delay=1, skip=False): def decorator(func): @wraps(func) async def wrapper(*args, **kwargs): @@ -115,6 +115,11 @@ async def wrapper(*args, **kwargs): if attempt < max_retries - 1: await asyncio.sleep(delay) continue + else: + if skip: + pytest.skip("403 Forbidden error. Skipping the test.") + else: + raise raise raise httpx.HTTPStatusError( request=e.request, diff --git a/v4-client-py-v2/tests/indexer/rest/modules/test_account_endpoints.py b/v4-client-py-v2/tests/indexer/rest/modules/test_account_endpoints.py index d7646ed0..3a1072e7 100644 --- a/v4-client-py-v2/tests/indexer/rest/modules/test_account_endpoints.py +++ b/v4-client-py-v2/tests/indexer/rest/modules/test_account_endpoints.py @@ -5,7 +5,7 @@ @pytest.mark.asyncio -@retry_on_forbidden(max_retries=3, delay=1) +@retry_on_forbidden(max_retries=3, delay=1, skip=True) async def test_subaccounts(indexer_rest_client, test_address): response = await indexer_rest_client.account.get_subaccounts(test_address) subaccounts = response["subaccounts"] @@ -17,7 +17,7 @@ async def test_subaccounts(indexer_rest_client, test_address): @pytest.mark.asyncio -@retry_on_forbidden(max_retries=3, delay=1) +@retry_on_forbidden(max_retries=3, delay=1, skip=True) async def test_subaccount_0(indexer_rest_client, test_address): response = await indexer_rest_client.account.get_subaccount(test_address, 0) subaccount = response["subaccount"] @@ -27,7 +27,7 @@ async def test_subaccount_0(indexer_rest_client, test_address): @pytest.mark.asyncio -@retry_on_forbidden(max_retries=3, delay=1) +@retry_on_forbidden(max_retries=3, delay=1, skip=True) async def test_asset_positions(indexer_rest_client, test_address): response = await indexer_rest_client.account.get_subaccount_asset_positions( test_address, 0 @@ -41,7 +41,7 @@ async def test_asset_positions(indexer_rest_client, test_address): @pytest.mark.asyncio -@retry_on_forbidden(max_retries=3, delay=1) +@retry_on_forbidden(max_retries=3, delay=1, skip=True) async def test_perpetual_positions(indexer_rest_client, test_address): response = await indexer_rest_client.account.get_subaccount_perpetual_positions( test_address, 0 @@ -55,7 +55,7 @@ async def test_perpetual_positions(indexer_rest_client, test_address): @pytest.mark.asyncio -@retry_on_forbidden(max_retries=3, delay=1) +@retry_on_forbidden(max_retries=3, delay=1, skip=True) async def test_transfers(indexer_rest_client, test_address): response = await indexer_rest_client.account.get_subaccount_transfers( test_address, 0 @@ -69,7 +69,7 @@ async def test_transfers(indexer_rest_client, test_address): @pytest.mark.asyncio -@retry_on_forbidden(max_retries=3, delay=1) +@retry_on_forbidden(max_retries=3, delay=1, skip=True) async def test_orders(indexer_rest_client, test_address): response = await indexer_rest_client.account.get_subaccount_orders(test_address, 0) assert response is not None @@ -81,7 +81,7 @@ async def test_orders(indexer_rest_client, test_address): @pytest.mark.asyncio -@retry_on_forbidden(max_retries=3, delay=1) +@retry_on_forbidden(max_retries=3, delay=1, skip=True) async def test_fills(indexer_rest_client, test_address): response = await indexer_rest_client.account.get_subaccount_fills(test_address, 0) assert response is not None @@ -93,7 +93,7 @@ async def test_fills(indexer_rest_client, test_address): @pytest.mark.asyncio -@retry_on_forbidden(max_retries=3, delay=1) +@retry_on_forbidden(max_retries=3, delay=1, skip=True) async def test_historical_pnl(indexer_rest_client, test_address): response = await indexer_rest_client.account.get_subaccount_historical_pnls( test_address, 0 @@ -107,7 +107,7 @@ async def test_historical_pnl(indexer_rest_client, test_address): @pytest.mark.asyncio -@retry_on_forbidden(max_retries=3, delay=1) +@retry_on_forbidden(max_retries=3, delay=1, skip=True) async def test_historical_block_trading_rewards(indexer_rest_client, test_address): limit = 10 response = await indexer_rest_client.account.get_historical_block_trading_rewards( @@ -124,7 +124,7 @@ async def test_historical_block_trading_rewards(indexer_rest_client, test_addres @pytest.mark.asyncio -@retry_on_forbidden(max_retries=3, delay=1) +@retry_on_forbidden(max_retries=3, delay=1, skip=True) async def test_historical_trading_rewards_aggregated(indexer_rest_client, test_address): period = TradingRewardAggregationPeriod.DAILY limit = 10