2024-01-10 19:01:56 +00:00
|
|
|
import pytest
|
|
|
|
|
|
|
|
from freqtrade.persistence import FtNoDBContext, PairLocks, Trade
|
|
|
|
|
|
|
|
|
2024-05-12 13:59:04 +00:00
|
|
|
@pytest.mark.parametrize("timeframe", ["", "5m", "1d"])
|
2024-01-10 19:01:56 +00:00
|
|
|
def test_FtNoDBContext(timeframe):
|
2024-05-12 13:59:04 +00:00
|
|
|
PairLocks.timeframe = ""
|
2024-01-10 19:01:56 +00:00
|
|
|
assert Trade.use_db is True
|
|
|
|
assert PairLocks.use_db is True
|
2024-05-12 13:59:04 +00:00
|
|
|
assert PairLocks.timeframe == ""
|
2024-01-10 19:01:56 +00:00
|
|
|
|
|
|
|
with FtNoDBContext(timeframe):
|
|
|
|
assert Trade.use_db is False
|
|
|
|
assert PairLocks.use_db is False
|
|
|
|
assert PairLocks.timeframe == timeframe
|
|
|
|
|
|
|
|
with FtNoDBContext():
|
|
|
|
assert Trade.use_db is False
|
|
|
|
assert PairLocks.use_db is False
|
2024-05-12 13:59:04 +00:00
|
|
|
assert PairLocks.timeframe == ""
|
2024-01-10 19:01:56 +00:00
|
|
|
|
|
|
|
assert Trade.use_db is True
|
|
|
|
assert PairLocks.use_db is True
|