Use correct timezone for tests

This commit is contained in:
Matthias 2020-10-26 07:36:25 +01:00
parent e602ac3406
commit 9c54c9a2bf
2 changed files with 5 additions and 4 deletions

View File

@ -2,7 +2,7 @@
Unit test file for rpc/api_server.py Unit test file for rpc/api_server.py
""" """
from datetime import datetime, timedelta from datetime import datetime, timedelta, timezone
from pathlib import Path from pathlib import Path
from unittest.mock import ANY, MagicMock, PropertyMock from unittest.mock import ANY, MagicMock, PropertyMock
@ -339,8 +339,8 @@ def test_api_locks(botclient):
assert rc.json['lock_count'] == 0 assert rc.json['lock_count'] == 0
assert rc.json['lock_count'] == len(rc.json['locks']) assert rc.json['lock_count'] == len(rc.json['locks'])
PairLocks.lock_pair('ETH/BTC', datetime.utcnow() + timedelta(minutes=4), 'randreason') PairLocks.lock_pair('ETH/BTC', datetime.now(timezone.utc) + timedelta(minutes=4), 'randreason')
PairLocks.lock_pair('XRP/BTC', datetime.utcnow() + timedelta(minutes=20), 'deadbeef') PairLocks.lock_pair('XRP/BTC', datetime.now(timezone.utc) + timedelta(minutes=20), 'deadbeef')
rc = client_get(client, f"{BASE_URI}/locks") rc = client_get(client, f"{BASE_URI}/locks")
assert_response(rc) assert_response(rc)

View File

@ -362,13 +362,14 @@ def test__analyze_ticker_internal_skip_analyze(ohlcv_history, mocker, caplog) ->
@pytest.mark.usefixtures("init_persistence") @pytest.mark.usefixtures("init_persistence")
def test_is_pair_locked(default_conf): def test_is_pair_locked(default_conf):
default_conf.update({'strategy': 'DefaultStrategy'}) default_conf.update({'strategy': 'DefaultStrategy'})
PairLocks.timeframe = default_conf['timeframe']
strategy = StrategyResolver.load_strategy(default_conf) strategy = StrategyResolver.load_strategy(default_conf)
# No lock should be present # No lock should be present
assert len(PairLocks.get_pair_locks(None)) == 0 assert len(PairLocks.get_pair_locks(None)) == 0
pair = 'ETH/BTC' pair = 'ETH/BTC'
assert not strategy.is_pair_locked(pair) assert not strategy.is_pair_locked(pair)
strategy.lock_pair(pair, arrow.utcnow().shift(minutes=4).datetime) strategy.lock_pair(pair, arrow.now(timezone.utc).shift(minutes=4).datetime)
# ETH/BTC locked for 4 minutes # ETH/BTC locked for 4 minutes
assert strategy.is_pair_locked(pair) assert strategy.is_pair_locked(pair)