19 lines
625 B
Python
19 lines
625 B
Python
from __future__ import annotations
|
|
|
|
from datetime import UTC, datetime
|
|
|
|
import pytest
|
|
from backup_tool.scheduler import ScheduleError, next_nominal
|
|
|
|
|
|
def test_five_field_cron_returns_utc_nominal_time() -> None:
|
|
result = next_nominal("0 9 * * *", "America/New_York", datetime(2026, 1, 1, tzinfo=UTC))
|
|
assert result.tzinfo is UTC
|
|
assert result.hour == 14
|
|
|
|
|
|
@pytest.mark.parametrize(("cron", "timezone"), [("* * * * * *", "UTC"), ("* * * * *", "Nope/Zone")])
|
|
def test_invalid_cron_or_timezone_is_rejected(cron: str, timezone: str) -> None:
|
|
with pytest.raises(ScheduleError):
|
|
next_nominal(cron, timezone)
|