def test_jsondatahandler_trades_purge(mocker, testdatadir): mocker.patch.object(Path, "exists", MagicMock(return_value=False)) mocker.patch.object(Path, "unlink", MagicMock()) dh = JsonGzDataHandler(testdatadir) assert not dh.trades_purge('UNITTEST/NONEXIST') mocker.patch.object(Path, "exists", MagicMock(return_value=True)) assert dh.trades_purge('UNITTEST/NONEXIST')
def test_jsondatahandler_trades_load(mocker, testdatadir, caplog): dh = JsonGzDataHandler(testdatadir) logmsg = "Old trades format detected - converting" dh.trades_load('XRP/ETH') assert not log_has(logmsg, caplog) # Test conversation is happening dh.trades_load('XRP/OLD') assert log_has(logmsg, caplog)
def test_jsondatahandler_ohlcv_purge(mocker, testdatadir): mocker.patch.object(Path, "exists", MagicMock(return_value=False)) unlinkmock = mocker.patch.object(Path, "unlink", MagicMock()) dh = JsonGzDataHandler(testdatadir) assert not dh.ohlcv_purge('UNITTEST/NONEXIST', '5m') assert unlinkmock.call_count == 0 mocker.patch.object(Path, "exists", MagicMock(return_value=True)) assert dh.ohlcv_purge('UNITTEST/NONEXIST', '5m') assert unlinkmock.call_count == 1
def test_jsondatahandler_trades_append(testdatadir): dh = JsonGzDataHandler(testdatadir) with pytest.raises(NotImplementedError): dh.trades_append('UNITTEST/ETH', [])
def test_jsondatahandler_ohlcv_append(testdatadir): dh = JsonGzDataHandler(testdatadir) with pytest.raises(NotImplementedError): dh.ohlcv_append('UNITTEST/ETH', '5m', DataFrame())