linting
	
		
			
	
		
	
	
		
	
		
			Some checks failed
		
		
	
	
		
			
				
	
				Build and deploy the backend to staging / Build and push image (pull_request) Successful in 2m9s
				
			
		
			
				
	
				Run linting on the backend code / Build (pull_request) Successful in 34s
				
			
		
			
				
	
				Run testing on the backend code / Build (pull_request) Failing after 1m56s
				
			
		
			
				
	
				Build and deploy the backend to staging / Deploy to staging (pull_request) Successful in 17s
				
			
		
		
	
	
				
					
				
			
		
			Some checks failed
		
		
	
	Build and deploy the backend to staging / Build and push image (pull_request) Successful in 2m9s
				
			Run linting on the backend code / Build (pull_request) Successful in 34s
				
			Run testing on the backend code / Build (pull_request) Failing after 1m56s
				
			Build and deploy the backend to staging / Deploy to staging (pull_request) Successful in 17s
				
			This commit is contained in:
		| @@ -402,7 +402,7 @@ preferred-modules= | ||||
|  | ||||
| # The type of string formatting that logging methods do. `old` means using % | ||||
| # formatting, `new` is for `{}` formatting. | ||||
| logging-format-style=old | ||||
| logging-format-style=new | ||||
|  | ||||
| # Logging modules to check that the string format arguments are in logging | ||||
| # function parameter format. | ||||
|   | ||||
| @@ -55,4 +55,3 @@ def configure_logging(): | ||||
|     logging.getLogger('uvicorn').handlers = logging_handlers | ||||
|     logging.getLogger('uvicorn.access').handlers = logging_handlers | ||||
|     logging.getLogger('uvicorn.error').handlers = logging_handlers | ||||
|  | ||||
|   | ||||
| @@ -2,8 +2,8 @@ | ||||
|  | ||||
| import logging | ||||
| import time | ||||
| from fastapi import FastAPI, HTTPException, Query | ||||
| from contextlib import asynccontextmanager | ||||
| from fastapi import FastAPI, HTTPException, Query | ||||
|  | ||||
| from .logging_config import configure_logging | ||||
| from .structs.landmark import Landmark, Toilets | ||||
|   | ||||
| @@ -138,5 +138,7 @@ class Toilets(BaseModel) : | ||||
|         return f'Toilets @{self.location}' | ||||
|  | ||||
|     class Config: | ||||
|         # This allows us to easily convert the model to and from dictionaries | ||||
|         """ | ||||
|         This allows us to easily convert the model to and from dictionaries | ||||
|         """ | ||||
|         from_attributes = True | ||||
| @@ -13,7 +13,7 @@ def client(): | ||||
|     return TestClient(app) | ||||
|  | ||||
|  | ||||
| def test_cache(client, request):    # pylint: disable=redefined-outer-name | ||||
| def test_cache(client):    # pylint: disable=redefined-outer-name | ||||
|     """ | ||||
|     Test n°1 : Custom test in Turckheim to ensure small villages are also supported. | ||||
|  | ||||
|   | ||||
| @@ -1,9 +1,9 @@ | ||||
| """Collection of tests to ensure correct implementation and track progress. """ | ||||
|  | ||||
| import time | ||||
| from fastapi.testclient import TestClient | ||||
| import pytest, time | ||||
| import pytest | ||||
|  | ||||
| from .test_utils import landmarks_to_osmid, load_trip_landmarks, log_trip_details | ||||
| from .test_utils import load_trip_landmarks, log_trip_details | ||||
| from ..main import app | ||||
|  | ||||
| @pytest.fixture(scope="module") | ||||
|   | ||||
| @@ -6,11 +6,13 @@ import pytest | ||||
| from ..structs.landmark import Toilets | ||||
| from ..main import app | ||||
|  | ||||
|  | ||||
| @pytest.fixture(scope="module") | ||||
| def client(): | ||||
|     """Client used to call the app.""" | ||||
|     return TestClient(app) | ||||
|  | ||||
|  | ||||
| @pytest.mark.parametrize( | ||||
|     "location,radius,status_code", | ||||
|     [ | ||||
| @@ -39,8 +41,6 @@ def test_invalid_input(client, location, radius, status_code):    # pylint: disa | ||||
|     assert response.status_code == status_code | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| @pytest.mark.parametrize( | ||||
|     "location,status_code", | ||||
|     [ | ||||
| @@ -66,11 +66,10 @@ def test_no_toilets(client, location, status_code):    # pylint: disable=redefin | ||||
|     toilets_list = [Toilets.model_validate(toilet) for toilet in response.json()] | ||||
|  | ||||
|     # checks : | ||||
|     assert response.status_code == 200  # check for successful planning | ||||
|     assert response.status_code == status_code  # check for successful planning | ||||
|     assert isinstance(toilets_list, list)  # check that the return type is a list | ||||
|  | ||||
|  | ||||
|  | ||||
| @pytest.mark.parametrize( | ||||
|     "location,status_code", | ||||
|     [ | ||||
| @@ -97,6 +96,6 @@ def test_toilets(client, location, status_code):    # pylint: disable=redefined- | ||||
|     toilets_list = [Toilets.model_validate(toilet) for toilet in response.json()] | ||||
|  | ||||
|     # checks : | ||||
|     assert response.status_code == 200  # check for successful planning | ||||
|     assert response.status_code == status_code  # check for successful planning | ||||
|     assert isinstance(toilets_list, list)  # check that the return type is a list | ||||
|     assert len(toilets_list) > 0 | ||||
| @@ -45,19 +45,19 @@ def fetch_landmark(client, landmark_uuid: str): | ||||
|         logger.info(f'API Response: {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") | ||||
|         raise HTTPException(status_code=500, detail="Invalid response format from API") from e | ||||
|  | ||||
|     # Try validating against the Landmark model here to ensure consistency | ||||
|     try: | ||||
|         landmark = Landmark(**json_data) | ||||
|     except ValidationError as ve: | ||||
|         logging.error(f'Validation error: {ve}') | ||||
|         raise HTTPException(status_code=500, detail="Invalid data format received from API") | ||||
|         raise HTTPException(status_code=500, detail="Invalid data format received from API") from ve | ||||
|  | ||||
|     if "detail" in json_data: | ||||
|         raise HTTPException(status_code=500, detail=json_data["detail"]) | ||||
|  | ||||
|     return Landmark(**json_data) | ||||
|     return landmark | ||||
|  | ||||
|  | ||||
| def fetch_landmark_cache(landmark_uuid: str): | ||||
|   | ||||
		Reference in New Issue
	
	Block a user