From b7c1d5549179ecd39f4e2c5b269b90df1e6a1be9 Mon Sep 17 00:00:00 2001 From: Matthias Date: Wed, 25 Dec 2019 16:41:52 +0100 Subject: [PATCH] Modify tests to point to datahandlers --- freqtrade/data/history.py | 20 -------------------- tests/data/test_history.py | 20 ++++++++++++++------ 2 files changed, 14 insertions(+), 26 deletions(-) diff --git a/freqtrade/data/history.py b/freqtrade/data/history.py index 1970f05d5..c83e91bac 100644 --- a/freqtrade/data/history.py +++ b/freqtrade/data/history.py @@ -76,20 +76,6 @@ def store_tickerdata_file(datadir: Path, pair: str, misc.file_dump_json(filename, data, is_zip=is_zip) -def load_trades_file(datadir: Path, pair: str, - timerange: Optional[TimeRange] = None) -> List[Dict]: - """ - Load a pair from file, either .json.gz or .json - :return: tradelist or empty list if unsuccesful - """ - filename = pair_trades_filename(datadir, pair) - tradesdata = misc.file_load_json(filename) - if not tradesdata: - return [] - - return tradesdata - - def load_pair_history(pair: str, timeframe: str, datadir: Path, *, @@ -198,12 +184,6 @@ def pair_data_filename(datadir: Path, pair: str, timeframe: str) -> Path: return filename -def pair_trades_filename(datadir: Path, pair: str) -> Path: - pair_s = pair.replace("/", "_") - filename = datadir.joinpath(f'{pair_s}-trades.json.gz') - return filename - - def _load_cached_data_for_updating(datadir: Path, pair: str, timeframe: str, timerange: Optional[TimeRange]) -> Tuple[List[Any], Optional[int]]: diff --git a/tests/data/test_history.py b/tests/data/test_history.py index 77cb6a565..fef7a3149 100644 --- a/tests/data/test_history.py +++ b/tests/data/test_history.py @@ -11,13 +11,14 @@ from pandas import DataFrame from freqtrade.configuration import TimeRange from freqtrade.data.datahandlers import get_datahandler +from freqtrade.data.datahandlers.jsondatahandler import (JsonDataHandler, + JsonGzDataHandler) from freqtrade.data.history import (_download_pair_history, _download_trades_history, _load_cached_data_for_updating, convert_trades_to_ohlcv, get_timerange, load_data, load_pair_history, - load_tickerdata_file, pair_data_filename, - pair_trades_filename, + load_tickerdata_file, refresh_backtest_ohlcv_data, refresh_backtest_trades_data, refresh_data, trim_tickerlist, validate_backtest_data) @@ -143,14 +144,21 @@ def test_testdata_path(testdatadir) -> None: assert str(Path('tests') / 'testdata') in str(testdatadir) -def test_pair_data_filename(): - fn = pair_data_filename(Path('freqtrade/hello/world'), 'ETH/BTC', '5m') +def test_json_pair_data_filename(): + fn = JsonDataHandler._pair_data_filename(Path('freqtrade/hello/world'), 'ETH/BTC', '5m') assert isinstance(fn, Path) assert fn == Path('freqtrade/hello/world/ETH_BTC-5m.json') + fn = JsonGzDataHandler._pair_data_filename(Path('freqtrade/hello/world'), 'ETH/BTC', '5m') + assert isinstance(fn, Path) + assert fn == Path('freqtrade/hello/world/ETH_BTC-5m.json.gz') -def test_pair_trades_filename(): - fn = pair_trades_filename(Path('freqtrade/hello/world'), 'ETH/BTC') +def test_json_pair_trades_filename(): + fn = JsonDataHandler._pair_trades_filename(Path('freqtrade/hello/world'), 'ETH/BTC') + assert isinstance(fn, Path) + assert fn == Path('freqtrade/hello/world/ETH_BTC-trades.json') + + fn = JsonGzDataHandler._pair_trades_filename(Path('freqtrade/hello/world'), 'ETH/BTC') assert isinstance(fn, Path) assert fn == Path('freqtrade/hello/world/ETH_BTC-trades.json.gz')