mirror of
https://code.lenaisten.de/Lenaisten/advent22.git
synced 2024-11-24 00:33:01 +00:00
88 lines
2 KiB
Python
88 lines
2 KiB
Python
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)),
|
|
close_after=5,
|
|
)
|
|
|
|
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)),
|
|
close_after=5,
|
|
)
|
|
|
|
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)),
|
|
close_after=5,
|
|
)
|
|
|
|
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)),
|
|
close_after=5,
|
|
)
|
|
|
|
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)),
|
|
close_after=8,
|
|
)
|
|
|
|
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)
|