Skip to content

Commit

Permalink
Fix weak test and 404 message
Browse files Browse the repository at this point in the history
  • Loading branch information
BielStela committed Apr 9, 2024
1 parent bdede6e commit 3a01188
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion api/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def path_params(raster_filename: Annotated[str, Query(description="Raster filena
tiff_path = get_settings().tiff_path
raster = os.path.join(tiff_path, raster_filename)
if not os.path.exists(raster):
raise HTTPException(status_code=404, detail=f"Raster file {raster} does not exist.")
raise HTTPException(status_code=404, detail=f"Raster file {raster_filename} does not exist.")
return raster


Expand Down
3 changes: 3 additions & 0 deletions api/tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,13 @@ def test_no_token():
assert response.status_code == 401
assert response.text == "Unauthorized"


def test_health_is_public():
response = test_client.get("/health")
assert response.status_code == 200
assert response.json() == {"status": "ok"}


def test_with_token(setup_data_folder):
response = test_client.get("/tifs", headers=HEADERS)
assert response.status_code == 200
Expand All @@ -121,6 +123,7 @@ def test_wrong_file_name_raises_404(setup_data_folder):
"/exact_zonal_stats", headers=HEADERS, params={"raster_filename": "wrong.tif"}, json=GEOJSON
)
assert response.status_code == 404
assert response.json() == {"detail": "Raster file wrong.tif does not exist."}


def test_no_geojson_raises_422(tif_file):
Expand Down

0 comments on commit 3a01188

Please sign in to comment.