Add some tests for hdf5

This commit is contained in:
Matthias 2020-07-24 19:37:37 +02:00
parent e26e658f99
commit 0a28818b46
4 changed files with 8 additions and 1 deletions

View File

@ -139,7 +139,8 @@ class HDF5DataHandler(IDataHandler):
column sequence as in DEFAULT_TRADES_COLUMNS column sequence as in DEFAULT_TRADES_COLUMNS
""" """
key = self._pair_trades_key(pair) key = self._pair_trades_key(pair)
ds = pd.HDFStore(self.filename_trades, mode='a', complevel=9, complib='blosc') ds = pd.HDFStore(self._pair_trades_filename(self._datadir, pair),
mode='a', complevel=9, complib='blosc')
ds.put(key, pd.DataFrame(data, columns=DEFAULT_TRADES_COLUMNS), ds.put(key, pd.DataFrame(data, columns=DEFAULT_TRADES_COLUMNS),
format='table', data_columns=['timestamp']) format='table', data_columns=['timestamp'])
ds.close() ds.close()

View File

@ -707,6 +707,12 @@ def test_datahandler_trades_append(datahandler, testdatadir):
dh.trades_append('UNITTEST/ETH', []) dh.trades_append('UNITTEST/ETH', [])
def test_hdf5datahandler_trades_get_pairs(testdatadir):
pairs = HDF5DataHandler.trades_get_pairs(testdatadir)
# Convert to set to avoid failures due to sorting
assert set(pairs) == {'XRP/ETH'}
def test_gethandlerclass(): def test_gethandlerclass():
cl = get_datahandlerclass('json') cl = get_datahandlerclass('json')
assert cl == JsonDataHandler assert cl == JsonDataHandler

BIN
tests/testdata/UNITTEST_BTC-5m.h5 vendored Normal file

Binary file not shown.

BIN
tests/testdata/XRP_ETH-trades.h5 vendored Normal file

Binary file not shown.