1616# License along with this library.
1717import decimal
1818
19+ import mock
1920from mock import patch
2021
2122import octobot_trading .exchanges .connectors as exchange_connectors
@@ -58,11 +59,13 @@ def set_markets(self, markets):
5859 def setSandboxMode (self , is_sandboxed ):
5960 pass
6061
61- with patch .object (ccxt_connector , 'client' , new = MockCCXT ()) as mocked_ccxt :
62+ with patch .object (ccxt_connector , 'client' , new = MockCCXT ()) as mocked_ccxt , \
63+ patch .object (ccxt_connector , '_ensure_auth' , new = mock .AsyncMock ()) as _ensure_auth_mock :
6264 await ccxt_connector .initialize_impl ()
6365 assert ccxt_connector .symbols == set ()
6466 assert ccxt_connector .time_frames == set ()
6567 assert mocked_ccxt .set_markets_calls in ([[]], []) # depends on call order
68+ _ensure_auth_mock .assert_called_once ()
6669
6770
6871async def test_initialize_impl_with_empty_symbols_and_timeframes (ccxt_connector ):
@@ -84,11 +87,13 @@ def set_markets(self, markets):
8487 def setSandboxMode (self , is_sandboxed ):
8588 pass
8689
87- with patch .object (ccxt_connector , 'client' , new = MockCCXT ()) as mocked_ccxt :
90+ with patch .object (ccxt_connector , 'client' , new = MockCCXT ()) as mocked_ccxt , \
91+ patch .object (ccxt_connector , '_ensure_auth' , new = mock .AsyncMock ()) as _ensure_auth_mock :
8892 await ccxt_connector .initialize_impl ()
8993 assert ccxt_connector .symbols == set ()
9094 assert ccxt_connector .time_frames == set ()
9195 assert mocked_ccxt .set_markets_calls in ([[]], []) # depends on call order
96+ _ensure_auth_mock .assert_called_once ()
9297
9398
9499async def test_initialize_impl (ccxt_connector ):
@@ -120,7 +125,8 @@ def set_markets(self, markets):
120125 def setSandboxMode (self , is_sandboxed ):
121126 pass
122127
123- with patch .object (ccxt_connector , 'client' , new = MockCCXT ()) as mocked_ccxt :
128+ with patch .object (ccxt_connector , 'client' , new = MockCCXT ()) as mocked_ccxt , \
129+ patch .object (ccxt_connector , '_ensure_auth' , new = mock .AsyncMock ()) as _ensure_auth_mock :
124130 await ccxt_connector .initialize_impl ()
125131 assert ccxt_connector .symbols == {
126132 "BTC/USDT" ,
@@ -133,6 +139,7 @@ def setSandboxMode(self, is_sandboxed):
133139 "4h" ,
134140 }
135141 assert mocked_ccxt .set_markets_calls in ([[]], []) # depends on call order
142+ _ensure_auth_mock .assert_called_once ()
136143
137144
138145async def test_set_symbol_partial_take_profit_stop_loss (ccxt_connector ):
0 commit comments