Modify tests to point to datahandlers

This commit is contained in:
Matthias 2019-12-25 16:41:52 +01:00
parent 9876d126ca
commit b7c1d55491
2 changed files with 14 additions and 26 deletions

View File

@ -76,20 +76,6 @@ def store_tickerdata_file(datadir: Path, pair: str,
misc.file_dump_json(filename, data, is_zip=is_zip) 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, def load_pair_history(pair: str,
timeframe: str, timeframe: str,
datadir: Path, *, datadir: Path, *,
@ -198,12 +184,6 @@ def pair_data_filename(datadir: Path, pair: str, timeframe: str) -> Path:
return filename 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, def _load_cached_data_for_updating(datadir: Path, pair: str, timeframe: str,
timerange: Optional[TimeRange]) -> Tuple[List[Any], timerange: Optional[TimeRange]) -> Tuple[List[Any],
Optional[int]]: Optional[int]]:

View File

@ -11,13 +11,14 @@ from pandas import DataFrame
from freqtrade.configuration import TimeRange from freqtrade.configuration import TimeRange
from freqtrade.data.datahandlers import get_datahandler from freqtrade.data.datahandlers import get_datahandler
from freqtrade.data.datahandlers.jsondatahandler import (JsonDataHandler,
JsonGzDataHandler)
from freqtrade.data.history import (_download_pair_history, from freqtrade.data.history import (_download_pair_history,
_download_trades_history, _download_trades_history,
_load_cached_data_for_updating, _load_cached_data_for_updating,
convert_trades_to_ohlcv, get_timerange, convert_trades_to_ohlcv, get_timerange,
load_data, load_pair_history, load_data, load_pair_history,
load_tickerdata_file, pair_data_filename, load_tickerdata_file,
pair_trades_filename,
refresh_backtest_ohlcv_data, refresh_backtest_ohlcv_data,
refresh_backtest_trades_data, refresh_data, refresh_backtest_trades_data, refresh_data,
trim_tickerlist, validate_backtest_data) trim_tickerlist, validate_backtest_data)
@ -143,14 +144,21 @@ def test_testdata_path(testdatadir) -> None:
assert str(Path('tests') / 'testdata') in str(testdatadir) assert str(Path('tests') / 'testdata') in str(testdatadir)
def test_pair_data_filename(): def test_json_pair_data_filename():
fn = pair_data_filename(Path('freqtrade/hello/world'), 'ETH/BTC', '5m') fn = JsonDataHandler._pair_data_filename(Path('freqtrade/hello/world'), 'ETH/BTC', '5m')
assert isinstance(fn, Path) assert isinstance(fn, Path)
assert fn == Path('freqtrade/hello/world/ETH_BTC-5m.json') 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(): def test_json_pair_trades_filename():
fn = pair_trades_filename(Path('freqtrade/hello/world'), 'ETH/BTC') 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 isinstance(fn, Path)
assert fn == Path('freqtrade/hello/world/ETH_BTC-trades.json.gz') assert fn == Path('freqtrade/hello/world/ETH_BTC-trades.json.gz')