Support inexact conference dates

Closes: #188
This commit is contained in:
Edward Betts 2026-06-22 09:25:51 +01:00
parent 14f5baf77c
commit 098c7e4447
9 changed files with 464 additions and 66 deletions

View file

@ -47,6 +47,33 @@ def test_insert_sorted_allows_same_url_different_year_without_year_component() -
assert updated[1]["name"] == "NewConf"
def test_insert_sorted_supports_nested_dates() -> None:
"""Nested dates should be used for sorting."""
conferences: list[dict[str, typing.Any]] = [
{
"name": "PyCascades",
"dates": {
"status": "approximate",
"label": "March 2027",
"earliest": date(2027, 3, 1),
"latest": date(2027, 3, 31),
},
}
]
new_conf: dict[str, typing.Any] = {
"name": "FOSDEM",
"dates": {
"status": "tentative",
"start": date(2027, 1, 30),
"end": date(2027, 1, 31),
},
}
updated = add_new_conference.insert_sorted(conferences, new_conf)
assert [conf["name"] for conf in updated] == ["FOSDEM", "PyCascades"]
def test_validate_country_normalises_name() -> None:
"""Country names should be normalised to alpha-2 codes."""
conf: dict[str, typing.Any] = {"country": "United Kingdom"}
@ -68,6 +95,21 @@ def test_normalise_end_field_defaults_single_day_date() -> None:
assert conf["end"] == date(2026, 4, 10)
def test_normalise_end_field_defaults_nested_exact_date() -> None:
"""Nested exact dates should get a default end date."""
conf: dict[str, typing.Any] = {
"name": "PyCon",
"dates": {
"status": "exact",
"start": date(2026, 4, 10),
},
}
add_new_conference.normalise_end_field(conf, "plain text")
assert conf["dates"]["end"] == date(2026, 4, 10)
def test_normalise_end_field_sets_geomob_end_time() -> None:
"""Geomob conferences should default to a 22:00 end time."""
conf: dict[str, typing.Any] = {