Skip to content

Commit 5c601bc

Browse files
committed
fix: formated and linted code
1 parent d5fcf91 commit 5c601bc

3 files changed

Lines changed: 24 additions & 16 deletions

File tree

app/services/ai_agents_service.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from app.core.config import settings
77
from app.schemas.health import ServiceHealth
8-
from app.schemas.itinary import Itinerary, Leg
8+
from app.schemas.itinary import Itinerary
99

1010
logger = logging.getLogger(__name__)
1111

@@ -68,11 +68,11 @@ async def health_check(self) -> ServiceHealth:
6868
async def get_itinerary_insight(self, itinerary: Itinerary) -> None:
6969
"""
7070
Get AI-generated insights for a complete itinerary and enrich it with AI data.
71-
71+
7272
This method sends the entire itinerary to the AI service and receives back:
7373
- ai_description: Overall description of the itinerary
7474
- ai_insights: List of insights for each leg
75-
75+
7676
The method directly modifies the itinerary object in place, setting:
7777
- itinerary.ai_description
7878
- leg.ai_insight for each leg
@@ -120,18 +120,18 @@ async def get_itinerary_insight(self, itinerary: Itinerary) -> None:
120120

121121
if response.status_code == 200:
122122
data = response.json()
123-
123+
124124
# Set the itinerary-level AI description
125125
itinerary.ai_description = data.get("ai_description")
126-
126+
127127
# Set AI insights for each leg
128128
ai_insights = data.get("ai_insights", [])
129129
for idx, leg in enumerate(itinerary.legs):
130130
if idx < len(ai_insights):
131131
leg.ai_insight = ai_insights[idx]
132132
else:
133133
leg.ai_insight = None
134-
134+
135135
return
136136

137137
logger.warning(

tests/endpoints/test_routes.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -442,11 +442,15 @@ def test_search_routes_with_ai_insights_success(client: TestClient, sample_itine
442442

443443
# Mock AI service to enrich itinerary in place
444444
async def mock_get_itinerary_insight(itinerary):
445-
itinerary.ai_description = "This route offers a good balance of walking and public transport."
445+
itinerary.ai_description = (
446+
"This route offers a good balance of walking and public transport."
447+
)
446448
itinerary.legs[0].ai_insight = "Short walk to the bus stop."
447449
itinerary.legs[1].ai_insight = "Express bus with comfortable seats."
448450

449-
mock_ai_service.get_itinerary_insight = AsyncMock(side_effect=mock_get_itinerary_insight)
451+
mock_ai_service.get_itinerary_insight = AsyncMock(
452+
side_effect=mock_get_itinerary_insight
453+
)
450454

451455
response = client.post(
452456
"/api/v1/routes/search",
@@ -490,7 +494,9 @@ async def mock_get_itinerary_insight_unavailable(itinerary):
490494
# Service unavailable - does not modify itinerary
491495
pass
492496

493-
mock_ai_service.get_itinerary_insight = AsyncMock(side_effect=mock_get_itinerary_insight_unavailable)
497+
mock_ai_service.get_itinerary_insight = AsyncMock(
498+
side_effect=mock_get_itinerary_insight_unavailable
499+
)
494500

495501
response = client.post(
496502
"/api/v1/routes/search",
@@ -527,7 +533,9 @@ async def mock_get_itinerary_insight_partial(itinerary):
527533
# Only set description, not leg insights
528534
itinerary.ai_description = "This is a good route."
529535

530-
mock_ai_service.get_itinerary_insight = AsyncMock(side_effect=mock_get_itinerary_insight_partial)
536+
mock_ai_service.get_itinerary_insight = AsyncMock(
537+
side_effect=mock_get_itinerary_insight_partial
538+
)
531539

532540
response = client.post(
533541
"/api/v1/routes/search",

tests/services/test_ai_agents_service.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,7 @@ async def test_get_itinerary_insight_success(ai_service, sample_itinerary):
185185
mock_response.status_code = 200
186186
mock_response.json.return_value = {
187187
"ai_description": "This route combines a short walk with a direct bus connection.",
188-
"ai_insights": [
189-
"Short walk to the bus stop.",
190-
"Express bus with comfortable seats."
191-
]
188+
"ai_insights": ["Short walk to the bus stop.", "Express bus with comfortable seats."],
192189
}
193190

194191
with patch.object(ai_service, "_get_client") as mock_get_client:
@@ -210,9 +207,12 @@ async def test_get_itinerary_insight_success(ai_service, sample_itinerary):
210207
assert len(payload["legs"]) == 2
211208
assert payload["legs"][0]["mode"] == "WALK"
212209
assert payload["legs"][1]["mode"] == "BUS"
213-
210+
214211
# Verify the itinerary was enriched
215-
assert sample_itinerary.ai_description == "This route combines a short walk with a direct bus connection."
212+
assert (
213+
sample_itinerary.ai_description
214+
== "This route combines a short walk with a direct bus connection."
215+
)
216216
assert sample_itinerary.legs[0].ai_insight == "Short walk to the bus stop."
217217
assert sample_itinerary.legs[1].ai_insight == "Express bus with comfortable seats."
218218

0 commit comments

Comments
 (0)