Add tests and documentation for unlock_reason
This commit is contained in:
@@ -116,3 +116,28 @@ def test_PairLocks_getlongestlock(use_db):
|
||||
|
||||
PairLocks.reset_locks()
|
||||
PairLocks.use_db = True
|
||||
|
||||
|
||||
@pytest.mark.parametrize('use_db', (False, True))
|
||||
@pytest.mark.usefixtures("init_persistence")
|
||||
def test_PairLocks_reason(use_db):
|
||||
PairLocks.timeframe = '5m'
|
||||
PairLocks.use_db = use_db
|
||||
# No lock should be present
|
||||
if use_db:
|
||||
assert len(PairLock.query.all()) == 0
|
||||
|
||||
assert PairLocks.use_db == use_db
|
||||
|
||||
PairLocks.lock_pair('XRP/USDT', arrow.utcnow().shift(minutes=4).datetime, 'TestLock1')
|
||||
PairLocks.lock_pair('ETH/USDT', arrow.utcnow().shift(minutes=4).datetime, 'TestLock2')
|
||||
|
||||
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.reset_locks()
|
||||
PairLocks.use_db = True
|
||||
|
@@ -575,6 +575,13 @@ def test_is_pair_locked(default_conf):
|
||||
strategy.unlock_pair(pair)
|
||||
assert not strategy.is_pair_locked(pair)
|
||||
|
||||
# Lock with reason
|
||||
reason = "TestLockR"
|
||||
strategy.lock_pair(pair, arrow.now(timezone.utc).shift(minutes=4).datetime, reason)
|
||||
assert strategy.is_pair_locked(pair)
|
||||
strategy.unlock_reason(reason)
|
||||
assert not strategy.is_pair_locked(pair)
|
||||
|
||||
pair = 'BTC/USDT'
|
||||
# Lock until 14:30
|
||||
lock_time = datetime(2020, 5, 1, 14, 30, 0, tzinfo=timezone.utc)
|
||||
|
Reference in New Issue
Block a user