mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-11-29 08:33:07 +00:00
ruff format: tests/plugins
This commit is contained in:
@@ -7,10 +7,10 @@ from freqtrade.persistence.models import PairLock
|
||||
from freqtrade.util import dt_now
|
||||
|
||||
|
||||
@pytest.mark.parametrize('use_db', (False, True))
|
||||
@pytest.mark.parametrize("use_db", (False, True))
|
||||
@pytest.mark.usefixtures("init_persistence")
|
||||
def test_PairLocks(use_db):
|
||||
PairLocks.timeframe = '5m'
|
||||
PairLocks.timeframe = "5m"
|
||||
PairLocks.use_db = use_db
|
||||
# No lock should be present
|
||||
if use_db:
|
||||
@@ -18,28 +18,28 @@ def test_PairLocks(use_db):
|
||||
|
||||
assert PairLocks.use_db == use_db
|
||||
|
||||
pair = 'ETH/BTC'
|
||||
pair = "ETH/BTC"
|
||||
assert not PairLocks.is_pair_locked(pair)
|
||||
PairLocks.lock_pair(pair, dt_now() + timedelta(minutes=4))
|
||||
# ETH/BTC locked for 4 minutes (on both sides)
|
||||
assert PairLocks.is_pair_locked(pair)
|
||||
assert PairLocks.is_pair_locked(pair, side='long')
|
||||
assert PairLocks.is_pair_locked(pair, side='short')
|
||||
assert PairLocks.is_pair_locked(pair, side="long")
|
||||
assert PairLocks.is_pair_locked(pair, side="short")
|
||||
|
||||
pair = 'BNB/BTC'
|
||||
PairLocks.lock_pair(pair, dt_now() + timedelta(minutes=4), side='long')
|
||||
pair = "BNB/BTC"
|
||||
PairLocks.lock_pair(pair, dt_now() + timedelta(minutes=4), side="long")
|
||||
assert not PairLocks.is_pair_locked(pair)
|
||||
assert PairLocks.is_pair_locked(pair, side='long')
|
||||
assert not PairLocks.is_pair_locked(pair, side='short')
|
||||
assert PairLocks.is_pair_locked(pair, side="long")
|
||||
assert not PairLocks.is_pair_locked(pair, side="short")
|
||||
|
||||
pair = 'BNB/USDT'
|
||||
PairLocks.lock_pair(pair, dt_now() + timedelta(minutes=4), side='short')
|
||||
pair = "BNB/USDT"
|
||||
PairLocks.lock_pair(pair, dt_now() + timedelta(minutes=4), side="short")
|
||||
assert not PairLocks.is_pair_locked(pair)
|
||||
assert not PairLocks.is_pair_locked(pair, side='long')
|
||||
assert PairLocks.is_pair_locked(pair, side='short')
|
||||
assert not PairLocks.is_pair_locked(pair, side="long")
|
||||
assert PairLocks.is_pair_locked(pair, side="short")
|
||||
|
||||
# XRP/BTC should not be locked now
|
||||
pair = 'XRP/BTC'
|
||||
pair = "XRP/BTC"
|
||||
assert not PairLocks.is_pair_locked(pair)
|
||||
# Unlocking a pair that's not locked should not raise an error
|
||||
PairLocks.unlock_pair(pair)
|
||||
@@ -52,12 +52,12 @@ def test_PairLocks(use_db):
|
||||
assert len(locks) == 2
|
||||
|
||||
# Unlock original pair
|
||||
pair = 'ETH/BTC'
|
||||
pair = "ETH/BTC"
|
||||
PairLocks.unlock_pair(pair)
|
||||
assert not PairLocks.is_pair_locked(pair)
|
||||
assert not PairLocks.is_global_lock()
|
||||
|
||||
pair = 'BTC/USDT'
|
||||
pair = "BTC/USDT"
|
||||
# Lock until 14:30
|
||||
lock_time = datetime(2020, 5, 1, 14, 30, 0, tzinfo=timezone.utc)
|
||||
PairLocks.lock_pair(pair, lock_time)
|
||||
@@ -73,18 +73,18 @@ def test_PairLocks(use_db):
|
||||
|
||||
locks = PairLocks.get_pair_locks(pair, lock_time + timedelta(minutes=-2))
|
||||
assert len(locks) == 1
|
||||
assert 'PairLock' in str(locks[0])
|
||||
assert "PairLock" in str(locks[0])
|
||||
|
||||
# Unlock all
|
||||
PairLocks.unlock_pair(pair, lock_time + timedelta(minutes=-2))
|
||||
assert not PairLocks.is_global_lock(lock_time + timedelta(minutes=-50))
|
||||
|
||||
# Global lock
|
||||
PairLocks.lock_pair('*', lock_time)
|
||||
PairLocks.lock_pair("*", lock_time)
|
||||
assert PairLocks.is_global_lock(lock_time + timedelta(minutes=-50))
|
||||
# Global lock also locks every pair separately
|
||||
assert PairLocks.is_pair_locked(pair, lock_time + timedelta(minutes=-50))
|
||||
assert PairLocks.is_pair_locked('XRP/USDT', lock_time + timedelta(minutes=-50))
|
||||
assert PairLocks.is_pair_locked("XRP/USDT", lock_time + timedelta(minutes=-50))
|
||||
|
||||
if use_db:
|
||||
locks = PairLocks.get_all_locks()
|
||||
@@ -100,10 +100,10 @@ def test_PairLocks(use_db):
|
||||
PairLocks.use_db = True
|
||||
|
||||
|
||||
@pytest.mark.parametrize('use_db', (False, True))
|
||||
@pytest.mark.parametrize("use_db", (False, True))
|
||||
@pytest.mark.usefixtures("init_persistence")
|
||||
def test_PairLocks_getlongestlock(use_db):
|
||||
PairLocks.timeframe = '5m'
|
||||
PairLocks.timeframe = "5m"
|
||||
# No lock should be present
|
||||
PairLocks.use_db = use_db
|
||||
if use_db:
|
||||
@@ -111,7 +111,7 @@ def test_PairLocks_getlongestlock(use_db):
|
||||
|
||||
assert PairLocks.use_db == use_db
|
||||
|
||||
pair = 'ETH/BTC'
|
||||
pair = "ETH/BTC"
|
||||
assert not PairLocks.is_pair_locked(pair)
|
||||
PairLocks.lock_pair(pair, dt_now() + timedelta(minutes=4))
|
||||
# ETH/BTC locked for 4 minutes
|
||||
@@ -132,10 +132,10 @@ def test_PairLocks_getlongestlock(use_db):
|
||||
PairLocks.use_db = True
|
||||
|
||||
|
||||
@pytest.mark.parametrize('use_db', (False, True))
|
||||
@pytest.mark.parametrize("use_db", (False, True))
|
||||
@pytest.mark.usefixtures("init_persistence")
|
||||
def test_PairLocks_reason(use_db):
|
||||
PairLocks.timeframe = '5m'
|
||||
PairLocks.timeframe = "5m"
|
||||
PairLocks.use_db = use_db
|
||||
# No lock should be present
|
||||
if use_db:
|
||||
@@ -143,15 +143,15 @@ def test_PairLocks_reason(use_db):
|
||||
|
||||
assert PairLocks.use_db == use_db
|
||||
|
||||
PairLocks.lock_pair('XRP/USDT', dt_now() + timedelta(minutes=4), 'TestLock1')
|
||||
PairLocks.lock_pair('ETH/USDT', dt_now() + timedelta(minutes=4), 'TestLock2')
|
||||
PairLocks.lock_pair("XRP/USDT", dt_now() + timedelta(minutes=4), "TestLock1")
|
||||
PairLocks.lock_pair("ETH/USDT", dt_now() + timedelta(minutes=4), "TestLock2")
|
||||
|
||||
assert PairLocks.is_pair_locked('XRP/USDT')
|
||||
assert PairLocks.is_pair_locked('ETH/USDT')
|
||||
assert PairLocks.is_pair_locked("XRP/USDT")
|
||||
assert PairLocks.is_pair_locked("ETH/USDT")
|
||||
|
||||
PairLocks.unlock_reason('TestLock1')
|
||||
assert not PairLocks.is_pair_locked('XRP/USDT')
|
||||
assert PairLocks.is_pair_locked('ETH/USDT')
|
||||
PairLocks.unlock_reason("TestLock1")
|
||||
assert not PairLocks.is_pair_locked("XRP/USDT")
|
||||
assert PairLocks.is_pair_locked("ETH/USDT")
|
||||
|
||||
PairLocks.reset_locks()
|
||||
PairLocks.use_db = True
|
||||
|
||||
Reference in New Issue
Block a user