Implement story 1.4: location resolution ICAO and address
Adds location.resolve() with ICAO CSV lookup and Nominatim geocoding, POST /find-location portal route with inline confirmation/error display, and full test coverage with mocked network calls. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
from planemapper.provisioning.portal import app
|
||||
@@ -45,3 +47,25 @@ def test_ncsi_redirects_to_index(client) -> None:
|
||||
def test_unknown_route_redirects_to_index(client) -> None:
|
||||
resp = client.get("/some/random/path")
|
||||
assert resp.status_code in (301, 302)
|
||||
|
||||
|
||||
def test_find_location_success(client) -> None:
|
||||
mock_resolve = patch(
|
||||
"planemapper.provisioning.portal.location.resolve", return_value=(51.5, -0.1, "London")
|
||||
)
|
||||
with mock_resolve:
|
||||
resp = client.post("/find-location", data={"location": "EGLL", "radius": "100"})
|
||||
assert resp.status_code == 200
|
||||
data = resp.data.decode()
|
||||
assert "London" in data
|
||||
assert "51.5" in data
|
||||
|
||||
|
||||
def test_find_location_error(client) -> None:
|
||||
with patch(
|
||||
"planemapper.provisioning.portal.location.resolve",
|
||||
side_effect=ValueError("ICAO code not found — try an address instead"),
|
||||
):
|
||||
resp = client.post("/find-location", data={"location": "ZZZZ", "radius": "100"})
|
||||
assert resp.status_code == 200
|
||||
assert "ICAO code not found" in resp.data.decode()
|
||||
|
||||
Reference in New Issue
Block a user