Add conference country filter
This commit is contained in:
parent
442ae98463
commit
38dbb2b4e7
3 changed files with 178 additions and 1 deletions
|
|
@ -6,6 +6,7 @@ from types import SimpleNamespace
|
|||
|
||||
import yaml
|
||||
|
||||
import agenda.fx
|
||||
import agenda.trip
|
||||
import web_view
|
||||
|
||||
|
|
@ -121,3 +122,84 @@ def test_conference_series_pages(tmp_path: typing.Any, monkeypatch: typing.Any)
|
|||
assert b"attended" in index_response.data
|
||||
assert detail_response.status_code == 200
|
||||
assert b"trip: Seattle Python trip" in detail_response.data
|
||||
|
||||
|
||||
def test_conference_page_filters_by_country(
|
||||
tmp_path: typing.Any, monkeypatch: typing.Any
|
||||
) -> None:
|
||||
"""Conference page should filter upcoming conferences by country code."""
|
||||
conferences = [
|
||||
{
|
||||
"name": "UK Mapping Conf 2099",
|
||||
"topic": "Maps",
|
||||
"location": "London",
|
||||
"country": "GB",
|
||||
"start": date(2099, 5, 1),
|
||||
"end": date(2099, 5, 2),
|
||||
},
|
||||
{
|
||||
"name": "US Python Conf 2099",
|
||||
"topic": "Python",
|
||||
"location": "Pittsburgh",
|
||||
"country": "US",
|
||||
"start": date(2099, 6, 1),
|
||||
"end": date(2099, 6, 2),
|
||||
},
|
||||
]
|
||||
(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: [])
|
||||
monkeypatch.setattr(agenda.fx, "get_rates", lambda config: {})
|
||||
|
||||
web_view.app.config["TESTING"] = True
|
||||
with web_view.app.test_client() as client:
|
||||
response = client.get("/conference?country=gb")
|
||||
|
||||
assert response.status_code == 200
|
||||
assert b"UK Mapping Conf 2099" in response.data
|
||||
assert b"US Python Conf 2099" not in response.data
|
||||
assert b'<option value="gb" selected>' in response.data
|
||||
assert b'href="/conference"' in response.data
|
||||
|
||||
|
||||
def test_past_conference_page_filters_by_country(
|
||||
tmp_path: typing.Any, monkeypatch: typing.Any
|
||||
) -> None:
|
||||
"""Past conference page should filter conferences by country code."""
|
||||
conferences = [
|
||||
{
|
||||
"name": "Past UK Conf",
|
||||
"topic": "Maps",
|
||||
"location": "London",
|
||||
"country": "GB",
|
||||
"start": date(2001, 5, 1),
|
||||
"end": date(2001, 5, 2),
|
||||
},
|
||||
{
|
||||
"name": "Past US Conf",
|
||||
"topic": "Python",
|
||||
"location": "Pittsburgh",
|
||||
"country": "US",
|
||||
"start": date(2001, 6, 1),
|
||||
"end": date(2001, 6, 2),
|
||||
},
|
||||
]
|
||||
(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: [])
|
||||
monkeypatch.setattr(agenda.fx, "get_rates", lambda config: {})
|
||||
|
||||
web_view.app.config["TESTING"] = True
|
||||
with web_view.app.test_client() as client:
|
||||
response = client.get("/conference/past?country=us")
|
||||
|
||||
assert response.status_code == 200
|
||||
assert b"Past US Conf" in response.data
|
||||
assert b"Past UK Conf" not in response.data
|
||||
assert b'href="/conference/past"' in response.data
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue