added more tests
This commit is contained in:
parent
4f194ab01c
commit
214e2a0c3b
|
@ -36,9 +36,9 @@ def test_window_simple_no_event(
|
||||||
"desired_break_window,days_passed_from_publication", [[1, 2], [2, 10], [4, 4]]
|
"desired_break_window,days_passed_from_publication", [[1, 2], [2, 10], [4, 4]]
|
||||||
)
|
)
|
||||||
def test_window_simple_event_found(
|
def test_window_simple_event_found(
|
||||||
event_generator, desired_break_window, days_passed_from_publication
|
event_generator, desired_break_window, days_passed_from_publication,
|
||||||
):
|
):
|
||||||
"Testing that the break between events is respected"
|
"Testing that the break between events is respected and an event is found"
|
||||||
unpublished_events = [
|
unpublished_events = [
|
||||||
event_generator(
|
event_generator(
|
||||||
published=False,
|
published=False,
|
||||||
|
@ -57,3 +57,48 @@ def test_window_simple_event_found(
|
||||||
minimum_break_between_events=timedelta(days=desired_break_window)
|
minimum_break_between_events=timedelta(days=desired_break_window)
|
||||||
).select(published_events, unpublished_events)
|
).select(published_events, unpublished_events)
|
||||||
assert selected_event is unpublished_events[0]
|
assert selected_event is unpublished_events[0]
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"desired_break_window,days_passed_from_publication", [[1, 2], [2, 10], [4, 4]]
|
||||||
|
)
|
||||||
|
def test_window_multi_event_found(
|
||||||
|
event_generator, desired_break_window, days_passed_from_publication,
|
||||||
|
):
|
||||||
|
"Testing that the break between events is respected when there are multiple events"
|
||||||
|
unpublished_events = [
|
||||||
|
event_generator(
|
||||||
|
published=False,
|
||||||
|
begin_date=datetime(year=2022, month=1, day=5, hour=11, minute=30),
|
||||||
|
),
|
||||||
|
event_generator(
|
||||||
|
published=False,
|
||||||
|
begin_date=datetime(year=2022, month=3, day=5, hour=11, minute=30),
|
||||||
|
),
|
||||||
|
event_generator(
|
||||||
|
published=False,
|
||||||
|
begin_date=datetime(year=2021, month=1, day=5, hour=11, minute=30),
|
||||||
|
),
|
||||||
|
]
|
||||||
|
published_events = [
|
||||||
|
event_generator(
|
||||||
|
published=True,
|
||||||
|
publication_time=datetime.now()
|
||||||
|
- timedelta(days=days_passed_from_publication),
|
||||||
|
),
|
||||||
|
event_generator(
|
||||||
|
published=True,
|
||||||
|
publication_time=datetime.now()
|
||||||
|
- timedelta(days=days_passed_from_publication + 2),
|
||||||
|
),
|
||||||
|
event_generator(
|
||||||
|
published=True,
|
||||||
|
publication_time=datetime.now()
|
||||||
|
- timedelta(days=days_passed_from_publication + 4),
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
||||||
|
selected_event = SelectNextEventStrategy(
|
||||||
|
minimum_break_between_events=timedelta(days=desired_break_window)
|
||||||
|
).select(published_events, unpublished_events)
|
||||||
|
assert selected_event is unpublished_events[0]
|
||||||
|
|
Loading…
Reference in New Issue