Drones to use AGL

This commit is contained in:
2026-06-29 06:26:37 -04:00
parent 4b6dd9c93c
commit 8d8cb9ccad
12 changed files with 82 additions and 23 deletions
+21 -4
View File
@@ -15,7 +15,7 @@ def drone_payload(**overrides):
"estimated_completion_time": "10:30",
"estimated_takeoff_at": "2026-06-20T10:00:00",
"estimated_completion_at": "2026-06-20T10:30:00",
"maximum_elevation_ft_amsl": 250,
"maximum_elevation_ft_agl": 250,
"location_description": "North apron",
"location_latitude": 51.623389,
"location_longitude": -4.069231,
@@ -81,6 +81,23 @@ def test_public_drone_request_create_edit_cancel_and_journal(client, db, monkeyp
assert client.delete("/api/v1/drone-requests/public/cancel/missing-token").status_code == 404
def test_drone_request_accepts_legacy_amsl_altitude_key(client, db, monkeypatch):
async def fake_send_email(**kwargs):
return True
monkeypatch.setattr("app.api.endpoints.drone_requests.email_service.send_email", fake_send_email)
payload = drone_payload()
payload["maximum_elevation_ft_amsl"] = payload.pop("maximum_elevation_ft_agl")
create_response = client.post("/api/v1/drone-requests/public", json=payload)
assert create_response.status_code == 200
assert create_response.json()["maximum_elevation_ft_agl"] == 250
db_request = db.query(DroneRequest).filter(DroneRequest.id == create_response.json()["id"]).one()
assert db_request.maximum_elevation_ft_agl == 250
def test_authenticated_drone_request_list_update_status_comment_and_journal(auth_client, db, monkeypatch):
sent_emails = []
@@ -100,7 +117,7 @@ def test_authenticated_drone_request_list_update_status_comment_and_journal(auth
get_response = auth_client.get(f"/api/v1/drone-requests/{created['id']}")
update_response = auth_client.patch(
f"/api/v1/drone-requests/{created['id']}",
json={"operator_comments": "Needs tower review", "maximum_elevation_ft_amsl": 200},
json={"operator_comments": "Needs tower review", "maximum_elevation_ft_agl": 200},
)
status_response = auth_client.patch(
f"/api/v1/drone-requests/{created['id']}/status",
@@ -116,7 +133,7 @@ def test_authenticated_drone_request_list_update_status_comment_and_journal(auth
assert [request["id"] for request in list_response.json()] == [created["id"]]
assert get_response.status_code == 200
assert update_response.status_code == 200
assert update_response.json()["maximum_elevation_ft_amsl"] == 200
assert update_response.json()["maximum_elevation_ft_agl"] == 200
assert status_response.status_code == 200
assert status_response.json()["status"] == "APPROVED"
assert status_response.json()["operator_comments"] == "Approved below 200ft"
@@ -133,7 +150,7 @@ def test_authenticated_drone_request_list_update_status_comment_and_journal(auth
def test_drone_request_not_found_and_validation_paths(auth_client, client):
invalid_response = client.post(
"/api/v1/drone-requests/public",
json=drone_payload(operator_name=" ", location_latitude=100, maximum_elevation_ft_amsl=-1),
json=drone_payload(operator_name=" ", location_latitude=100, maximum_elevation_ft_agl=-1),
)
assert invalid_response.status_code == 422