first commit
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from app.main import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
|
||||
def test_healthcheck() -> None:
|
||||
response = client.get("/health")
|
||||
assert response.status_code == 200
|
||||
assert response.json() == {"status": "ok"}
|
||||
|
||||
|
||||
def test_openapi_contains_expected_paths() -> None:
|
||||
response = client.get("/openapi.json")
|
||||
assert response.status_code == 200
|
||||
paths = response.json()["paths"]
|
||||
assert "/api/v1/terrain/profile" in paths
|
||||
assert "/api/v1/terrain/los" in paths
|
||||
assert "/api/v1/link/budget" in paths
|
||||
assert "/api/v1/coverage" in paths
|
||||
|
||||
|
||||
def test_profile_endpoint_returns_geodesic_samples() -> None:
|
||||
response = client.post(
|
||||
"/api/v1/terrain/profile",
|
||||
json={
|
||||
"start": {"lat": 60.17, "lon": 24.94},
|
||||
"end": {"lat": 60.25, "lon": 25.10},
|
||||
"samples": 4,
|
||||
"include_buildings": True,
|
||||
"include_canopy": True,
|
||||
"k_factor": 1.333,
|
||||
},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert data["distance_m"] > 0
|
||||
assert len(data["samples"]) == 4
|
||||
assert data["path_geojson"]["type"] == "LineString"
|
||||
|
||||
|
||||
def test_elevation_returns_not_implemented_without_dem() -> None:
|
||||
response = client.get("/api/v1/terrain/elevation", params={"lat": 60.17, "lon": 24.94})
|
||||
assert response.status_code == 501
|
||||
|
||||
|
||||
def test_manual_link_budget_endpoint() -> None:
|
||||
response = client.post(
|
||||
"/api/v1/link/budget",
|
||||
json={
|
||||
"tx": {"lat": 60.17, "lon": 24.94, "height_agl": 30, "power_dbm": 37, "gain_dbi": 8},
|
||||
"rx": {
|
||||
"lat": 60.25,
|
||||
"lon": 25.10,
|
||||
"height_agl": 2,
|
||||
"gain_dbi": 2,
|
||||
"sensitivity_dbm": -110,
|
||||
},
|
||||
"frequency_mhz": 433,
|
||||
"model": "manual",
|
||||
"include_buildings": True,
|
||||
"include_vegetation": True,
|
||||
"k_factor": 1.333,
|
||||
},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert data["fspl_db"] > 0
|
||||
assert data["link_viable"] is True
|
||||
Reference in New Issue
Block a user