File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed
trading_backend/exchanges Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change 20
20
import trading_backend .exchanges as exchanges
21
21
import trading_backend .errors
22
22
import trading_backend .enums
23
+ from trading_backend .exchanges .exchange import ProxyConnectionError
23
24
from tests import default_exchange
24
25
25
26
@@ -49,6 +50,12 @@ async def test_is_valid_account(default_exchange):
49
50
with pytest .raises (trading_backend .errors .APIKeyPermissionsError ):
50
51
assert await exchange .is_valid_account () == (True , None )
51
52
fetch_balance_mock .assert_called_once ()
53
+ with mock .patch .object (exchange ._exchange .connector .client , "fetch_balance" ,
54
+ mock .AsyncMock (side_effect = ProxyConnectionError )) as fetch_balance_mock :
55
+ # non ccxt error: proceed to right checks and raise
56
+ with pytest .raises (trading_backend .errors .UnexpectedError ):
57
+ assert await exchange .is_valid_account () == (True , None )
58
+ fetch_balance_mock .assert_called_once ()
52
59
with mock .patch .object (exchange ._exchange .connector .client , "fetch_balance" ,
53
60
mock .AsyncMock (side_effect = ccxt .InvalidNonce )) as fetch_balance_mock :
54
61
with pytest .raises (trading_backend .errors .TimeSyncError ):
Original file line number Diff line number Diff line change 15
15
# License along with this library.
16
16
import ccxt
17
17
import contextlib
18
+ try :
19
+ from aiohttp_socks import ProxyConnectionError
20
+ except ImportError :
21
+ # local mock in case aiohttp_socks is not available
22
+ class ProxyConnectionError (Exception ):
23
+ pass
18
24
19
25
import trading_backend .errors
20
26
import trading_backend .enums
@@ -199,7 +205,7 @@ def error_describer(self):
199
205
"""
200
206
try :
201
207
yield
202
- except (ccxt .ExchangeNotAvailable , ccxt .AuthenticationError ) as err :
208
+ except (ccxt .ExchangeNotAvailable , ccxt .AuthenticationError , ProxyConnectionError ) as err :
203
209
try :
204
210
self ._exchange .connector .raise_or_prefix_proxy_error_if_relevant (err , None )
205
211
except ccxt .BaseError :
You can’t perform that action at this time.
0 commit comments