mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-15 04:33:57 +00:00
Merge pull request #10860 from xzmeng/fix-test-download-data-timerange
tests: fix failure when local timezone is not utc
This commit is contained in:
commit
dafabd5b99
|
@ -44,7 +44,7 @@ from freqtrade.enums import RunMode
|
||||||
from freqtrade.exceptions import OperationalException
|
from freqtrade.exceptions import OperationalException
|
||||||
from freqtrade.persistence.models import init_db
|
from freqtrade.persistence.models import init_db
|
||||||
from freqtrade.persistence.pairlock_middleware import PairLocks
|
from freqtrade.persistence.pairlock_middleware import PairLocks
|
||||||
from freqtrade.util import dt_floor_day, dt_now, dt_utc
|
from freqtrade.util import dt_utc
|
||||||
from tests.conftest import (
|
from tests.conftest import (
|
||||||
CURRENT_TEST_STRATEGY,
|
CURRENT_TEST_STRATEGY,
|
||||||
EXMS,
|
EXMS,
|
||||||
|
@ -757,7 +757,13 @@ def test_download_data_keyboardInterrupt(mocker, markets):
|
||||||
assert dl_mock.call_count == 1
|
assert dl_mock.call_count == 1
|
||||||
|
|
||||||
|
|
||||||
def test_download_data_timerange(mocker, markets):
|
@pytest.mark.parametrize("time", ["00:00", "00:03", "00:30", "23:56"])
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"tzoffset",
|
||||||
|
["00:00", "+01:00", "-01:00", "+05:00", "-05:00"],
|
||||||
|
)
|
||||||
|
def test_download_data_timerange(mocker, markets, time_machine, time, tzoffset):
|
||||||
|
time_machine.move_to(f"2024-11-01 {time}:00 {tzoffset}")
|
||||||
dl_mock = mocker.patch(
|
dl_mock = mocker.patch(
|
||||||
"freqtrade.data.history.history_utils.refresh_backtest_ohlcv_data",
|
"freqtrade.data.history.history_utils.refresh_backtest_ohlcv_data",
|
||||||
MagicMock(return_value=["ETH/BTC", "XRP/BTC"]),
|
MagicMock(return_value=["ETH/BTC", "XRP/BTC"]),
|
||||||
|
@ -797,8 +803,9 @@ def test_download_data_timerange(mocker, markets):
|
||||||
start_download_data(pargs)
|
start_download_data(pargs)
|
||||||
assert dl_mock.call_count == 1
|
assert dl_mock.call_count == 1
|
||||||
# 20days ago
|
# 20days ago
|
||||||
days_ago = dt_floor_day(dt_now() - timedelta(days=20)).timestamp()
|
days_ago = datetime.now() - timedelta(days=20)
|
||||||
assert dl_mock.call_args_list[0][1]["timerange"].startts == days_ago
|
days_ago = dt_utc(days_ago.year, days_ago.month, days_ago.day)
|
||||||
|
assert dl_mock.call_args_list[0][1]["timerange"].startts == days_ago.timestamp()
|
||||||
|
|
||||||
dl_mock.reset_mock()
|
dl_mock.reset_mock()
|
||||||
args = [
|
args = [
|
||||||
|
|
Loading…
Reference in New Issue
Block a user