Improve test coverage
This commit is contained in:
parent
c02497e4b8
commit
3cdb672ac3
@ -13,7 +13,8 @@ from freqtrade.data.btanalysis import (BT_DATA_COLUMNS, analyze_trade_parallelis
|
||||
calculate_underwater, combine_dataframes_with_mean,
|
||||
create_cum_profit, extract_trades_of_period,
|
||||
get_latest_backtest_filename, get_latest_hyperopt_file,
|
||||
load_backtest_data, load_trades, load_trades_from_db)
|
||||
load_backtest_data, load_backtest_metadata, load_trades,
|
||||
load_trades_from_db)
|
||||
from freqtrade.data.history import load_data, load_pair_history
|
||||
from freqtrade.exceptions import OperationalException
|
||||
from tests.conftest import create_mock_trades
|
||||
@ -40,7 +41,7 @@ def test_get_latest_backtest_filename(testdatadir, mocker):
|
||||
get_latest_backtest_filename(testdatadir)
|
||||
|
||||
|
||||
def test_get_latest_hyperopt_file(testdatadir, mocker):
|
||||
def test_get_latest_hyperopt_file(testdatadir):
|
||||
res = get_latest_hyperopt_file(testdatadir / 'does_not_exist', 'testfile.pickle')
|
||||
assert res == testdatadir / 'does_not_exist/testfile.pickle'
|
||||
|
||||
@ -51,6 +52,17 @@ def test_get_latest_hyperopt_file(testdatadir, mocker):
|
||||
assert res == testdatadir.parent / "hyperopt_results.pickle"
|
||||
|
||||
|
||||
def test_load_backtest_metadata(mocker, testdatadir):
|
||||
res = load_backtest_metadata(testdatadir / 'nonexistant.file.json')
|
||||
assert res == {}
|
||||
|
||||
mocker.patch('freqtrade.data.btanalysis.get_backtest_metadata_filename')
|
||||
mocker.patch('freqtrade.data.btanalysis.json_load', side_effect=Exception())
|
||||
with pytest.raises(OperationalException,
|
||||
match=r"Unexpected error.*loading backtest metadata\."):
|
||||
load_backtest_metadata(testdatadir / 'nonexistant.file.json')
|
||||
|
||||
|
||||
def test_load_backtest_data_old_format(testdatadir, mocker):
|
||||
|
||||
filename = testdatadir / "backtest-result_test222.json"
|
||||
|
Loading…
Reference in New Issue
Block a user