Validate weekends year range and fix trip page unbooked-flight helper call
This commit is contained in:
parent
f9b79d5a51
commit
0c88ad4638
4 changed files with 123 additions and 5 deletions
31
tests/test_weekends_route.py
Normal file
31
tests/test_weekends_route.py
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue