Validate weekends year range and fix trip page unbooked-flight helper call

This commit is contained in:
Edward Betts 2026-03-07 13:10:33 +00:00
parent f9b79d5a51
commit 0c88ad4638
4 changed files with 123 additions and 5 deletions

View file

@ -0,0 +1,31 @@
"""Tests for weekends route query validation."""
from datetime import date
import typing
import pytest
import web_view
@pytest.fixture # type: ignore[untyped-decorator]
def client() -> typing.Any:
"""Flask test client."""
web_view.app.config["TESTING"] = True
with web_view.app.test_client() as c:
yield c
def test_weekends_rejects_year_before_2020(client: typing.Any) -> None:
"""Years before 2020 should return HTTP 400."""
response = client.get("/weekends?year=2019&week=1")
assert response.status_code == 400
assert b"Year must be between 2020" in response.data
def test_weekends_rejects_year_more_than_five_years_ahead(client: typing.Any) -> None:
"""Years beyond current year + 5 should return HTTP 400."""
too_far = date.today().year + 6
response = client.get(f"/weekends?year={too_far}&week=1")
assert response.status_code == 400
assert b"Year must be between 2020" in response.data