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
				
			
		
		
	
	
				
					
				
			
		
			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:
		
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| @@ -69,7 +69,7 @@ def new_trip(preferences: Preferences, | |||||||
|                             osm_id=0, |                             osm_id=0, | ||||||
|                             attractiveness=0, |                             attractiveness=0, | ||||||
|                             must_do=True, |                             must_do=True, | ||||||
|                             n_tags = 0) |                             n_tags=0) | ||||||
|  |  | ||||||
|     # Generate the landmarks from the start location |     # Generate the landmarks from the start location | ||||||
|     landmarks, landmarks_short = manager.generate_landmarks_list( |     landmarks, landmarks_short = manager.generate_landmarks_list( | ||||||
| @@ -132,6 +132,8 @@ def get_landmark(landmark_uuid: str) -> Landmark: | |||||||
|     """ |     """ | ||||||
|     try: |     try: | ||||||
|         landmark = cache_client.get(f"landmark_{landmark_uuid}") |         landmark = cache_client.get(f"landmark_{landmark_uuid}") | ||||||
|  |         if not isinstance(landmark, Landmark) : | ||||||
|  |             raise ValueError(f"Object {landmark} is not of type Landmark") | ||||||
|         return landmark |         return landmark | ||||||
|     except KeyError as exc: |     except KeyError as exc: | ||||||
|         raise HTTPException(status_code=404, detail="Landmark not found") from exc |         raise HTTPException(status_code=404, detail="Landmark not found") from exc | ||||||
|   | |||||||
| @@ -73,8 +73,6 @@ class Landmark(BaseModel) : | |||||||
|         t_to_next_str = f", time_to_next={self.time_to_reach_next}" if self.time_to_reach_next else "" |         t_to_next_str = f", time_to_next={self.time_to_reach_next}" if self.time_to_reach_next else "" | ||||||
|         is_secondary_str = ", secondary" if self.is_secondary else "" |         is_secondary_str = ", secondary" if self.is_secondary else "" | ||||||
|         type_str = '(' + self.type + ')' |         type_str = '(' + self.type + ')' | ||||||
|         if self.type in ["start", "finish", "nature", "shopping"] : |  | ||||||
|             type_str += '\t ' |  | ||||||
|  |  | ||||||
|         return (f'Landmark{type_str}: [{self.name} @{self.location}, ' |         return (f'Landmark{type_str}: [{self.name} @{self.location}, ' | ||||||
|                 f'score={self.attractiveness}{t_to_next_str}{is_secondary_str}]') |                 f'score={self.attractiveness}{t_to_next_str}{is_secondary_str}]') | ||||||
|   | |||||||
| @@ -1,4 +1,5 @@ | |||||||
| """Helper methods for testing.""" | """Helper methods for testing.""" | ||||||
|  | import logging | ||||||
| from typing import List | from typing import List | ||||||
| from fastapi import HTTPException | from fastapi import HTTPException | ||||||
|  |  | ||||||
| @@ -31,17 +32,23 @@ def fetch_landmark(client, landmark_uuid: str): | |||||||
|     Returns: |     Returns: | ||||||
|         dict: Landmark data fetched from the API. |         dict: Landmark data fetched from the API. | ||||||
|     """ |     """ | ||||||
|  |     logger = logging.getLogger(__name__) | ||||||
|     response = client.get(f"/landmark/{landmark_uuid}") |     response = client.get(f"/landmark/{landmark_uuid}") | ||||||
|  |  | ||||||
|     if response.status_code != 200: |     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}") |                             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: |     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 |     return json_data | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user