test: enhance now_is_time_to_refresh test

This commit is contained in:
Matthias
2025-05-22 20:03:43 +02:00
parent f0b16c277c
commit 34ccf141d1

View File

@@ -2136,6 +2136,21 @@ def test___now_is_time_to_refresh(default_conf, mocker, exchange_name, time_mach
time_machine.move_to(start_dt + timedelta(minutes=5, seconds=1), tick=False)
assert exchange._now_is_time_to_refresh(pair, "5m", candle_type) is True
# Test with 1d data
start_day_dt = datetime(2023, 12, 1, 0, 0, 0, tzinfo=timezone.utc)
last_closed_candle_1d = dt_ts(start_day_dt - timedelta(days=1))
exchange._pairs_last_refresh_time[(pair, "1d", candle_type)] = last_closed_candle_1d
time_machine.move_to(start_day_dt - timedelta(seconds=5), tick=False)
assert exchange._now_is_time_to_refresh(pair, "1d", candle_type) is False
time_machine.move_to(start_day_dt + timedelta(hours=20, seconds=5), tick=False)
assert exchange._now_is_time_to_refresh(pair, "1d", candle_type) is False
# Next candle closed - now we refresh.
time_machine.move_to(start_day_dt + timedelta(days=1, seconds=0), tick=False)
assert exchange._now_is_time_to_refresh(pair, "1d", candle_type) is True
@pytest.mark.parametrize("candle_type", ["mark", ""])
@pytest.mark.parametrize("exchange_name", EXCHANGES)