Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use UTC explicitly in timetable tests
Browse files Browse the repository at this point in the history
These tests logically depend on the fact that the test suite is run in
UTC. While that is true and expected to remain this way for the
foreseeable future, it is better to make them use UTC explicitly.

Note that timetables are expected to return times in UTC anyway.
uranusjr committed Dec 7, 2023

Verified

This commit was signed with the committer’s verified signature.
alexsapran Alexandros Sapranidis
1 parent 3904206 commit ca75462
Showing 4 changed files with 132 additions and 133 deletions.
30 changes: 15 additions & 15 deletions tests/timetables/test_events_timetable.py
Original file line number Diff line number Diff line change
@@ -20,31 +20,31 @@
import pendulum
import pytest

from airflow.settings import TIMEZONE
from airflow.timetables.base import DagRunInfo, DataInterval, TimeRestriction, Timetable
from airflow.timetables.events import EventsTimetable
from airflow.utils.timezone import utc

START_DATE = pendulum.DateTime(2021, 9, 4, tzinfo=TIMEZONE) # Precedes all events
START_DATE = pendulum.DateTime(2021, 9, 4, tzinfo=utc) # Precedes all events

EVENT_DATES = [
pendulum.DateTime(2021, 9, 6, tzinfo=TIMEZONE),
pendulum.DateTime(2021, 9, 7, tzinfo=TIMEZONE),
pendulum.DateTime(2021, 9, 8, tzinfo=TIMEZONE),
pendulum.DateTime(2021, 9, 8, tzinfo=TIMEZONE), # deliberate duplicate, should be ignored
pendulum.DateTime(2021, 10, 9, tzinfo=TIMEZONE), # deliberately out of order
pendulum.DateTime(2021, 9, 10, tzinfo=TIMEZONE),
pendulum.DateTime(2021, 9, 6, tzinfo=utc),
pendulum.DateTime(2021, 9, 7, tzinfo=utc),
pendulum.DateTime(2021, 9, 8, tzinfo=utc),
pendulum.DateTime(2021, 9, 8, tzinfo=utc), # deliberate duplicate, should be ignored
pendulum.DateTime(2021, 10, 9, tzinfo=utc), # deliberately out of order
pendulum.DateTime(2021, 9, 10, tzinfo=utc),
]

EVENT_DATES_SORTED = [
pendulum.DateTime(2021, 9, 6, tzinfo=TIMEZONE),
pendulum.DateTime(2021, 9, 7, tzinfo=TIMEZONE),
pendulum.DateTime(2021, 9, 8, tzinfo=TIMEZONE),
pendulum.DateTime(2021, 9, 10, tzinfo=TIMEZONE),
pendulum.DateTime(2021, 10, 9, tzinfo=TIMEZONE),
pendulum.DateTime(2021, 9, 6, tzinfo=utc),
pendulum.DateTime(2021, 9, 7, tzinfo=utc),
pendulum.DateTime(2021, 9, 8, tzinfo=utc),
pendulum.DateTime(2021, 9, 10, tzinfo=utc),
pendulum.DateTime(2021, 10, 9, tzinfo=utc),
]

NON_EVENT_DATE = pendulum.DateTime(2021, 10, 1, tzinfo=TIMEZONE)
MOST_RECENT_EVENT = pendulum.DateTime(2021, 9, 10, tzinfo=TIMEZONE)
NON_EVENT_DATE = pendulum.DateTime(2021, 10, 1, tzinfo=utc)
MOST_RECENT_EVENT = pendulum.DateTime(2021, 9, 10, tzinfo=utc)


@pytest.fixture()
Loading

0 comments on commit ca75462

Please sign in to comment.