Improve exception wording

This commit is contained in:
Matthias 2023-09-25 19:48:09 +02:00
parent 9e6cc5ebbd
commit 74709461e3
2 changed files with 8 additions and 1 deletions

View File

@ -7,6 +7,7 @@ from freqtrade.constants import DATETIME_PRINT_FORMAT, DEFAULT_TRADES_COLUMNS, C
from freqtrade.data.converter.trade_converter import (trades_convert_types,
trades_df_remove_duplicates)
from freqtrade.data.history.idatahandler import get_datahandler
from freqtrade.exceptions import OperationalException
from freqtrade.resolvers import ExchangeResolver
@ -20,7 +21,7 @@ def import_kraken_trades_from_csv(config: Config, convert_to: str):
Import kraken trades from csv
"""
if config['exchange']['name'] != 'kraken':
raise ValueError('This function is only for kraken exchange')
raise OperationalException('This function is only for the kraken exchange.')
datadir: Path = config['datadir']
data_handler = get_datahandler(datadir, data_format=convert_to)

View File

@ -3,12 +3,18 @@ from pathlib import Path
from shutil import copytree
from unittest.mock import PropertyMock
import pytest
from freqtrade.data.converter.trade_converter_kraken import import_kraken_trades_from_csv
from freqtrade.data.history.idatahandler import get_datahandler
from freqtrade.exceptions import OperationalException
from tests.conftest import EXMS, log_has, log_has_re, patch_exchange
def test_import_kraken_trades_from_csv(testdatadir, tmpdir, caplog, default_conf_usdt, mocker):
with pytest.raises(OperationalException, match="This function is only for the kraken exchange"):
import_kraken_trades_from_csv(default_conf_usdt, 'feather')
default_conf_usdt['exchange']['name'] = 'kraken'
patch_exchange(mocker, id='kraken')