Files
planeMapper/tests/provisioning/test_airspace.py
Matt Edholm 4aeeefb488 Implement story 1.5: provisioning execution tile download cache validation wifi kill
Add tiles.py, airspace.py, wifi.join_home_wifi, portal /submit route, and rewire
provision.py main loop; all tasks and quality gates pass (56 tests, ruff clean).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-22 22:54:34 -04:00

32 lines
1.1 KiB
Python

import json
from pathlib import Path
from unittest.mock import MagicMock, patch
import pytest
from planemapper.provisioning.airspace import download
def test_download_no_api_key(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
airspace_path = tmp_path / "airspace.geojson"
monkeypatch.delenv("OPENAIP_API_KEY", raising=False)
with patch("planemapper.provisioning.airspace.AIRSPACE_PATH", airspace_path):
download(51.5, -0.1, 100)
data = json.loads(airspace_path.read_text())
assert data["type"] == "FeatureCollection"
assert data["features"] == []
def test_download_with_api_key(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
airspace_path = tmp_path / "airspace.geojson"
monkeypatch.setenv("OPENAIP_API_KEY", "testkey123")
mock_resp = MagicMock()
mock_resp.ok = True
mock_resp.text = '{"type":"FeatureCollection","features":[]}'
with (
patch("planemapper.provisioning.airspace.requests.get", return_value=mock_resp),
patch("planemapper.provisioning.airspace.AIRSPACE_PATH", airspace_path),
):
download(51.5, -0.1, 100)
assert airspace_path.exists()