2023-09-20 14:25:10 +00:00
|
|
|
from datetime import date
|
|
|
|
|
|
|
|
from advent22_api.core.helpers import EventDates
|
|
|
|
|
|
|
|
|
|
|
|
def test_get_before():
|
|
|
|
today = date(2023, 11, 30)
|
|
|
|
|
|
|
|
ed = EventDates(
|
|
|
|
today=today,
|
|
|
|
begin_month=12,
|
|
|
|
begin_day=1,
|
|
|
|
events=list(range(1, 25)),
|
2023-09-20 16:14:58 +00:00
|
|
|
close_after=5,
|
2023-09-20 14:25:10 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
assert ed.first == date(2023, 12, 1)
|
|
|
|
assert ed.get_next(today=today) == date(2023, 12, 1)
|
|
|
|
assert ed.last == date(2023, 12, 24)
|
|
|
|
assert ed.end == date(2023, 12, 29)
|
|
|
|
|
|
|
|
|
|
|
|
def test_get_after():
|
|
|
|
today = date(2023, 12, 30)
|
|
|
|
|
|
|
|
ed = EventDates(
|
|
|
|
today=today,
|
|
|
|
begin_month=12,
|
|
|
|
begin_day=1,
|
|
|
|
events=list(range(1, 25)),
|
2023-09-20 16:14:58 +00:00
|
|
|
close_after=5,
|
2023-09-20 14:25:10 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
assert ed.first == date(2024, 12, 1)
|
|
|
|
assert ed.get_next(today=today) == date(2024, 12, 1)
|
|
|
|
assert ed.last == date(2024, 12, 24)
|
|
|
|
assert ed.end == date(2024, 12, 29)
|
|
|
|
|
|
|
|
|
|
|
|
def test_get_during_events():
|
|
|
|
today = date(2023, 12, 10)
|
|
|
|
|
|
|
|
ed = EventDates(
|
|
|
|
today=today,
|
|
|
|
begin_month=12,
|
|
|
|
begin_day=1,
|
|
|
|
events=list(range(1, 25)),
|
2023-09-20 16:14:58 +00:00
|
|
|
close_after=5,
|
2023-09-20 14:25:10 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
assert ed.first == date(2023, 12, 1)
|
|
|
|
assert ed.get_next(today=today) == date(2023, 12, 11)
|
|
|
|
assert ed.last == date(2023, 12, 24)
|
|
|
|
assert ed.end == date(2023, 12, 29)
|
|
|
|
|
|
|
|
|
|
|
|
def test_get_during_closing():
|
|
|
|
today = date(2023, 12, 29)
|
|
|
|
|
|
|
|
ed = EventDates(
|
|
|
|
today=today,
|
|
|
|
begin_month=12,
|
|
|
|
begin_day=1,
|
|
|
|
events=list(range(1, 25)),
|
2023-09-20 16:14:58 +00:00
|
|
|
close_after=5,
|
2023-09-20 14:25:10 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
assert ed.first == date(2023, 12, 1)
|
|
|
|
assert ed.get_next(today=today) is None
|
|
|
|
assert ed.last == date(2023, 12, 24)
|
|
|
|
assert ed.end == date(2023, 12, 29)
|
|
|
|
|
|
|
|
|
|
|
|
def test_get_during_wrap():
|
|
|
|
today = date(2024, 1, 1)
|
|
|
|
|
|
|
|
ed = EventDates(
|
|
|
|
today=today,
|
|
|
|
begin_month=12,
|
|
|
|
begin_day=1,
|
|
|
|
events=list(range(1, 25)),
|
2023-09-20 16:14:58 +00:00
|
|
|
close_after=8,
|
2023-09-20 14:25:10 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
assert ed.first == date(2023, 12, 1)
|
|
|
|
assert ed.get_next(today=today) is None
|
|
|
|
assert ed.last == date(2023, 12, 24)
|
|
|
|
assert ed.end == date(2024, 1, 1)
|