more error checking
Some checks failed
Build and deploy the backend to staging / Build and push image (pull_request) Successful in 2m40s
Run linting on the backend code / Build (pull_request) Successful in 28s
Run testing on the backend code / Build (pull_request) Failing after 1m23s
Build and deploy the backend to staging / Deploy to staging (pull_request) Successful in 15s

This commit is contained in:
2024-12-13 07:48:39 +01:00
parent edf2f3af72
commit f0873ff313
4 changed files with 16 additions and 9 deletions

View File

@@ -1,4 +1,5 @@
"""Helper methods for testing."""
import logging
from typing import List
from fastapi import HTTPException
@@ -31,17 +32,23 @@ def fetch_landmark(client, landmark_uuid: str):
Returns:
dict: Landmark data fetched from the API.
"""
logger = logging.getLogger(__name__)
response = client.get(f"/landmark/{landmark_uuid}")
if response.status_code != 200:
raise HTTPException(status_code=999,
raise HTTPException(status_code=500,
detail=f"Failed to fetch landmark with UUID {landmark_uuid}: {response.status_code}")
json_data = response.json()
try:
json_data = response.json()
logger.info(f"API Response: {json_data}")
print(f"API Response of type {type(json_data)} in json format: {json_data}")
except ValueError as e:
logger.error(f"Failed to parse response as JSON: {response.text}")
raise HTTPException(status_code=500, detail="Invalid response format from API")
if "detail" in json_data:
raise HTTPException(status_code=999, detail=json_data["detail"])
raise HTTPException(status_code=500, detail=json_data["detail"])
return json_data