test: add test-case for improved error-handling
This commit is contained in:
@@ -416,7 +416,17 @@ def test_hdf5datahandler_ohlcv_load_and_resave(
|
|||||||
)
|
)
|
||||||
@pytest.mark.parametrize("datahandler", ["hdf5", "feather", "parquet"])
|
@pytest.mark.parametrize("datahandler", ["hdf5", "feather", "parquet"])
|
||||||
def test_generic_datahandler_ohlcv_load_and_resave(
|
def test_generic_datahandler_ohlcv_load_and_resave(
|
||||||
datahandler, testdatadir, tmp_path, pair, timeframe, candle_type, candle_append, startdt, enddt
|
datahandler,
|
||||||
|
mocker,
|
||||||
|
testdatadir,
|
||||||
|
tmp_path,
|
||||||
|
pair,
|
||||||
|
timeframe,
|
||||||
|
candle_type,
|
||||||
|
candle_append,
|
||||||
|
startdt,
|
||||||
|
enddt,
|
||||||
|
caplog,
|
||||||
):
|
):
|
||||||
tmpdir2 = tmp_path
|
tmpdir2 = tmp_path
|
||||||
if candle_type not in ("", "spot"):
|
if candle_type not in ("", "spot"):
|
||||||
@@ -458,9 +468,26 @@ def test_generic_datahandler_ohlcv_load_and_resave(
|
|||||||
assert ohlcv[ohlcv["date"] > enddt].empty
|
assert ohlcv[ohlcv["date"] > enddt].empty
|
||||||
|
|
||||||
# Try loading inexisting file
|
# Try loading inexisting file
|
||||||
ohlcv = dh.ohlcv_load("UNITTEST/NONEXIST", timeframe, candle_type=candle_type)
|
ohlcv = dh1.ohlcv_load("UNITTEST/NONEXIST", timeframe, candle_type=candle_type)
|
||||||
assert ohlcv.empty
|
assert ohlcv.empty
|
||||||
|
|
||||||
|
# Try loading a file that exists but errors
|
||||||
|
mocker.patch(
|
||||||
|
"freqtrade.data.history.datahandlers.featherdatahandler.read_feather",
|
||||||
|
side_effect=Exception("Test"),
|
||||||
|
)
|
||||||
|
mocker.patch(
|
||||||
|
"freqtrade.data.history.datahandlers.parquetdatahandler.read_parquet",
|
||||||
|
side_effect=Exception("Test"),
|
||||||
|
)
|
||||||
|
mocker.patch(
|
||||||
|
"freqtrade.data.history.datahandlers.hdf5datahandler.pd.read_hdf",
|
||||||
|
side_effect=Exception("Test"),
|
||||||
|
)
|
||||||
|
ohlcv_e = dh1.ohlcv_load("UNITTEST/NEW", timeframe, candle_type=candle_type)
|
||||||
|
assert ohlcv_e.empty
|
||||||
|
assert log_has_re("Error loading data from", caplog)
|
||||||
|
|
||||||
|
|
||||||
def test_hdf5datahandler_ohlcv_purge(mocker, testdatadir):
|
def test_hdf5datahandler_ohlcv_purge(mocker, testdatadir):
|
||||||
mocker.patch.object(Path, "exists", MagicMock(return_value=False))
|
mocker.patch.object(Path, "exists", MagicMock(return_value=False))
|
||||||
|
|||||||
Reference in New Issue
Block a user