Add rudimentary tests for pg-specific stuff

This commit is contained in:
Matthias 2022-02-06 14:06:46 +01:00
parent bd4014e1e6
commit 8f2425e49f

View File

@ -13,6 +13,7 @@ from sqlalchemy import create_engine, text
from freqtrade import constants
from freqtrade.exceptions import DependencyException, OperationalException
from freqtrade.persistence import LocalTrade, Order, Trade, clean_dry_run_db, init_db
from freqtrade.persistence.migrations import get_last_sequence_ids, set_sequence_ids
from tests.conftest import create_mock_trades, create_mock_trades_usdt, log_has, log_has_re
@ -679,6 +680,38 @@ def test_migrate_mid_state(mocker, default_conf, fee, caplog):
caplog)
def test_migrate_get_last_sequence_ids():
engine = MagicMock()
engine.begin = MagicMock()
engine.name = 'postgresql'
get_last_sequence_ids(engine, 'trades_bak', 'orders_bak')
assert engine.begin.call_count == 2
engine.reset_mock()
engine.begin.reset_mock()
engine.name = 'somethingelse'
get_last_sequence_ids(engine, 'trades_bak', 'orders_bak')
assert engine.begin.call_count == 0
def test_migrate_set_sequence_ids():
engine = MagicMock()
engine.begin = MagicMock()
engine.name = 'postgresql'
set_sequence_ids(engine, 22, 55)
assert engine.begin.call_count == 1
engine.reset_mock()
engine.begin.reset_mock()
engine.name = 'somethingelse'
set_sequence_ids(engine, 22, 55)
assert engine.begin.call_count == 0
def test_adjust_stop_loss(fee):
trade = Trade(
pair='ADA/USDT',