Remove sandbox related code
This commit is contained in:
@@ -263,8 +263,6 @@ class Exchange:
|
|||||||
except ccxt.BaseError as e:
|
except ccxt.BaseError as e:
|
||||||
raise OperationalException(f"Initialization of ccxt failed. Reason: {e}") from e
|
raise OperationalException(f"Initialization of ccxt failed. Reason: {e}") from e
|
||||||
|
|
||||||
self.set_sandbox(api, exchange_config, name)
|
|
||||||
|
|
||||||
return api
|
return api
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@@ -465,16 +463,6 @@ class Exchange:
|
|||||||
return amount_to_contract_precision(amount, self.get_precision_amount(pair),
|
return amount_to_contract_precision(amount, self.get_precision_amount(pair),
|
||||||
self.precisionMode, contract_size)
|
self.precisionMode, contract_size)
|
||||||
|
|
||||||
def set_sandbox(self, api: ccxt.Exchange, exchange_config: dict, name: str) -> None:
|
|
||||||
if exchange_config.get('sandbox'):
|
|
||||||
if api.urls.get('test'):
|
|
||||||
api.urls['api'] = api.urls['test']
|
|
||||||
logger.info("Enabled Sandbox API on %s", name)
|
|
||||||
else:
|
|
||||||
logger.warning(
|
|
||||||
f"No Sandbox URL in CCXT for {name}, exiting. Please check your config.json")
|
|
||||||
raise OperationalException(f'Exchange {name} does not provide a sandbox api')
|
|
||||||
|
|
||||||
def _load_async_markets(self, reload: bool = False) -> None:
|
def _load_async_markets(self, reload: bool = False) -> None:
|
||||||
try:
|
try:
|
||||||
if self._api_async:
|
if self._api_async:
|
||||||
|
|||||||
@@ -556,41 +556,6 @@ def test_get_min_pair_stake_amount_real_data(mocker, default_conf) -> None:
|
|||||||
assert result == 4000
|
assert result == 4000
|
||||||
|
|
||||||
|
|
||||||
def test_set_sandbox(default_conf, mocker):
|
|
||||||
"""
|
|
||||||
Test working scenario
|
|
||||||
"""
|
|
||||||
api_mock = MagicMock()
|
|
||||||
api_mock.load_markets = MagicMock(return_value={
|
|
||||||
'ETH/BTC': '', 'LTC/BTC': '', 'XRP/BTC': '', 'NEO/BTC': ''
|
|
||||||
})
|
|
||||||
url_mock = PropertyMock(return_value={'test': "api-public.sandbox.gdax.com",
|
|
||||||
'api': 'https://api.gdax.com'})
|
|
||||||
type(api_mock).urls = url_mock
|
|
||||||
exchange = get_patched_exchange(mocker, default_conf, api_mock)
|
|
||||||
liveurl = exchange._api.urls['api']
|
|
||||||
default_conf['exchange']['sandbox'] = True
|
|
||||||
exchange.set_sandbox(exchange._api, default_conf['exchange'], 'Logname')
|
|
||||||
assert exchange._api.urls['api'] != liveurl
|
|
||||||
|
|
||||||
|
|
||||||
def test_set_sandbox_exception(default_conf, mocker):
|
|
||||||
"""
|
|
||||||
Test Fail scenario
|
|
||||||
"""
|
|
||||||
api_mock = MagicMock()
|
|
||||||
api_mock.load_markets = MagicMock(return_value={
|
|
||||||
'ETH/BTC': '', 'LTC/BTC': '', 'XRP/BTC': '', 'NEO/BTC': ''
|
|
||||||
})
|
|
||||||
url_mock = PropertyMock(return_value={'api': 'https://api.gdax.com'})
|
|
||||||
type(api_mock).urls = url_mock
|
|
||||||
|
|
||||||
with pytest.raises(OperationalException, match=r'does not provide a sandbox api'):
|
|
||||||
exchange = get_patched_exchange(mocker, default_conf, api_mock)
|
|
||||||
default_conf['exchange']['sandbox'] = True
|
|
||||||
exchange.set_sandbox(exchange._api, default_conf['exchange'], 'Logname')
|
|
||||||
|
|
||||||
|
|
||||||
def test__load_async_markets(default_conf, mocker, caplog):
|
def test__load_async_markets(default_conf, mocker, caplog):
|
||||||
mocker.patch(f'{EXMS}._init_ccxt')
|
mocker.patch(f'{EXMS}._init_ccxt')
|
||||||
mocker.patch(f'{EXMS}.validate_pairs')
|
mocker.patch(f'{EXMS}.validate_pairs')
|
||||||
|
|||||||
Reference in New Issue
Block a user