parent
14f5baf77c
commit
098c7e4447
9 changed files with 464 additions and 66 deletions
|
|
@ -8,7 +8,7 @@ from typing import Any
|
|||
import pytest
|
||||
import yaml
|
||||
|
||||
from agenda.conference import Conference, get_list
|
||||
from agenda.conference import Conference, conference_date_fields, get_list
|
||||
from agenda.event import Event
|
||||
|
||||
|
||||
|
|
@ -298,6 +298,104 @@ class TestGetList:
|
|||
assert event.date == datetime(2024, 5, 15, 9, 0)
|
||||
assert event.end_date == datetime(2024, 5, 17, 17, 0)
|
||||
|
||||
def test_get_list_nested_exact_dates(self) -> None:
|
||||
"""Test reading conference with nested exact dates."""
|
||||
yaml_data = [
|
||||
{
|
||||
"name": "PyCon",
|
||||
"topic": "Python",
|
||||
"location": "Portland",
|
||||
"dates": {
|
||||
"status": "exact",
|
||||
"start": date(2024, 5, 15),
|
||||
"end": date(2024, 5, 17),
|
||||
},
|
||||
}
|
||||
]
|
||||
|
||||
with tempfile.NamedTemporaryFile(mode="w", suffix=".yaml", delete=False) as f:
|
||||
yaml.dump(yaml_data, f)
|
||||
f.flush()
|
||||
|
||||
events = get_list(f.name)
|
||||
|
||||
assert len(events) == 1
|
||||
assert events[0].date == date(2024, 5, 15)
|
||||
assert events[0].end_date == date(2024, 5, 17)
|
||||
|
||||
def test_get_list_tentative_dates_do_not_create_conference_event(self) -> None:
|
||||
"""Test tentative conference dates are not emitted as calendar events."""
|
||||
yaml_data = [
|
||||
{
|
||||
"name": "FOSDEM",
|
||||
"topic": "FOSDEM",
|
||||
"location": "Brussels",
|
||||
"dates": {
|
||||
"status": "tentative",
|
||||
"start": date(2027, 1, 30),
|
||||
"end": date(2027, 1, 31),
|
||||
"label": "likely first weekend of February 2027",
|
||||
},
|
||||
}
|
||||
]
|
||||
|
||||
with tempfile.NamedTemporaryFile(mode="w", suffix=".yaml", delete=False) as f:
|
||||
yaml.dump(yaml_data, f)
|
||||
f.flush()
|
||||
|
||||
events = get_list(f.name)
|
||||
|
||||
assert events == []
|
||||
|
||||
def test_get_list_approximate_dates_keep_cfp_event(self) -> None:
|
||||
"""Test approximate dates do not block CFP reminders."""
|
||||
yaml_data = [
|
||||
{
|
||||
"name": "PyCascades",
|
||||
"topic": "Python",
|
||||
"location": "TBC",
|
||||
"dates": {
|
||||
"status": "approximate",
|
||||
"label": "March 2027",
|
||||
"earliest": date(2027, 3, 1),
|
||||
"latest": date(2027, 3, 31),
|
||||
},
|
||||
"cfp_end": date(2026, 11, 1),
|
||||
}
|
||||
]
|
||||
|
||||
with tempfile.NamedTemporaryFile(mode="w", suffix=".yaml", delete=False) as f:
|
||||
yaml.dump(yaml_data, f)
|
||||
f.flush()
|
||||
|
||||
events = get_list(f.name)
|
||||
|
||||
assert len(events) == 1
|
||||
assert events[0].name == "cfp_end"
|
||||
assert events[0].date == date(2026, 11, 1)
|
||||
|
||||
def test_conference_date_fields_approximate(self) -> None:
|
||||
"""Test derived fields for approximate conference dates."""
|
||||
fields = conference_date_fields(
|
||||
{
|
||||
"name": "PyCascades",
|
||||
"topic": "Python",
|
||||
"location": "TBC",
|
||||
"dates": {
|
||||
"status": "approximate",
|
||||
"label": "March 2027",
|
||||
"earliest": date(2027, 3, 1),
|
||||
"latest": date(2027, 3, 31),
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
assert fields["date_status"] == "approximate"
|
||||
assert fields["sort_date"] == date(2027, 3, 1)
|
||||
assert fields["latest_date"] == date(2027, 3, 31)
|
||||
assert fields["display_date"] == "March 2027"
|
||||
assert fields["has_exact_dates"] is False
|
||||
|
||||
def test_get_list_invalid_date_order(self) -> None:
|
||||
"""Test that conferences with end before start raise assertion error."""
|
||||
yaml_data = [
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue