80 lines
2.4 KiB
Python
80 lines
2.4 KiB
Python
from datetime import datetime
|
|
|
|
from advent22_api.core.helpers import EventDays
|
|
|
|
|
|
class TestEventDays:
|
|
@staticmethod
|
|
def test_get_before():
|
|
ed = EventDays.get(
|
|
today=datetime(2023, 11, 30).date(),
|
|
begin_month=12,
|
|
begin_day=1,
|
|
events_after=list(range(24)),
|
|
closing_after=5,
|
|
)
|
|
|
|
assert ed.first == datetime(2023, 12, 1).date()
|
|
assert ed.next == datetime(2023, 12, 1).date()
|
|
assert ed.last == datetime(2023, 12, 24).date()
|
|
assert ed.end == datetime(2023, 12, 29).date()
|
|
|
|
@staticmethod
|
|
def test_get_after():
|
|
ed = EventDays.get(
|
|
today=datetime(2023, 12, 30).date(),
|
|
begin_month=12,
|
|
begin_day=1,
|
|
events_after=list(range(24)),
|
|
closing_after=5,
|
|
)
|
|
|
|
assert ed.first == datetime(2024, 12, 1).date()
|
|
assert ed.next == datetime(2024, 12, 1).date()
|
|
assert ed.last == datetime(2024, 12, 24).date()
|
|
assert ed.end == datetime(2024, 12, 29).date()
|
|
|
|
@staticmethod
|
|
def test_get_during_events():
|
|
ed = EventDays.get(
|
|
today=datetime(2023, 12, 10).date(),
|
|
begin_month=12,
|
|
begin_day=1,
|
|
events_after=list(range(24)),
|
|
closing_after=5,
|
|
)
|
|
|
|
assert ed.first == datetime(2023, 12, 1).date()
|
|
assert ed.next == datetime(2023, 12, 11).date()
|
|
assert ed.last == datetime(2023, 12, 24).date()
|
|
assert ed.end == datetime(2023, 12, 29).date()
|
|
|
|
@staticmethod
|
|
def test_get_during_closing():
|
|
ed = EventDays.get(
|
|
today=datetime(2023, 12, 29).date(),
|
|
begin_month=12,
|
|
begin_day=1,
|
|
events_after=list(range(24)),
|
|
closing_after=5,
|
|
)
|
|
|
|
assert ed.first == datetime(2023, 12, 1).date()
|
|
assert ed.next is None
|
|
assert ed.last == datetime(2023, 12, 24).date()
|
|
assert ed.end == datetime(2023, 12, 29).date()
|
|
|
|
@staticmethod
|
|
def test_get_during_wrap():
|
|
ed = EventDays.get(
|
|
today=datetime(2024, 1, 1).date(),
|
|
begin_month=12,
|
|
begin_day=1,
|
|
events_after=list(range(24)),
|
|
closing_after=8,
|
|
)
|
|
|
|
assert ed.first == datetime(2023, 12, 1).date()
|
|
assert ed.next is None
|
|
assert ed.last == datetime(2023, 12, 24).date()
|
|
assert ed.end == datetime(2024, 1, 1).date()
|