"""Tests for conference list date handling.""" from datetime import date import typing import yaml import agenda.trip import web_view def test_build_conference_list_supports_inexact_dates( tmp_path: typing.Any, monkeypatch: typing.Any ) -> None: """Conference list should include tentative and approximate dates.""" conferences = [ { "name": "PyCascades 2027", "topic": "Python", "location": "TBC", "dates": { "status": "approximate", "label": "March 2027", "earliest": date(2027, 3, 1), "latest": date(2027, 3, 31), }, }, { "name": "FOSDEM 2027", "topic": "FOSDEM", "location": "Brussels", "dates": { "status": "tentative", "start": date(2027, 1, 30), "end": date(2027, 1, 31), "label": "likely first weekend of February 2027", }, }, ] (tmp_path / "conferences.yaml").write_text( yaml.safe_dump(conferences), encoding="utf-8" ) monkeypatch.setitem(web_view.app.config, "PERSONAL_DATA", str(tmp_path)) monkeypatch.setattr(agenda.trip, "build_trip_list", lambda: []) items = web_view.build_conference_list() assert [item["name"] for item in items] == ["FOSDEM 2027", "PyCascades 2027"] assert items[0]["date_status"] == "tentative" assert items[0]["display_date"] == "likely first weekend of February 2027" assert items[0]["sort_date"] == date(2027, 1, 30) assert items[1]["date_status"] == "approximate" assert items[1]["display_date"] == "March 2027" assert items[1]["latest_date"] == date(2027, 3, 31)