Skip to content

Commit 30a10c7

Browse files
author
Lukasz Kawka
committed
fix: issues flaged by gemini
1 parent d83a7fc commit 30a10c7

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

tests/e2e/push_notifications/agent_app.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def test_agent_card(url: str) -> AgentCard:
4141
AgentSkill(
4242
id='greeting',
4343
name='Greeting Agent',
44-
description='just greats the user',
44+
description='just greets the user',
4545
tags=['greeting'],
4646
examples=['Hello Agent!', 'How are you?'],
4747
)
@@ -64,7 +64,7 @@ async def invoke(
6464
):
6565
await updater.failed(
6666
new_agent_text_message(
67-
'Unsupported mesesage.', task.context_id, task.id
67+
'Unsupported message.', task.context_id, task.id
6868
)
6969
)
7070
return
@@ -122,7 +122,7 @@ async def execute(
122122
async def cancel(
123123
self, context: RequestContext, event_queue: EventQueue
124124
) -> None:
125-
raise Exception('cancel not supported')
125+
raise NotImplementedError('cancel not supported')
126126

127127

128128
def create_agent_app(

tests/e2e/push_notifications/notifications_app.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,31 @@
22

33
from typing import Annotated
44

5-
from fastapi import FastAPI, Path, Request
5+
from fastapi import FastAPI, Path, Request, HTTPException
66

77

88
def create_notifications_app() -> FastAPI:
99
"""Creates a simple push notification injesting HTTP+REST application."""
1010
app = FastAPI()
1111
store_lock = asyncio.Lock()
12-
store = {}
12+
store: dict[str, list] = {}
1313

1414
@app.post('/notifications')
1515
async def add_notification(request: Request):
1616
"""Endpoint for injesting notifications from agents. It receives a JSON
1717
payload and stores it in-memory.
1818
"""
1919
if not request.headers.get('x-a2a-notification-token'):
20-
raise ValueError('Missing x-a2a-notification-token header.')
20+
raise HTTPException(
21+
status_code=400,
22+
detail='Missing "x-a2a-notification-token" header.',
23+
)
2124
payload = await request.json()
22-
task_id = payload['id']
25+
task_id = payload.get('id')
26+
if not task_id:
27+
raise HTTPException(
28+
status_code=400, detail='Missing "id" in notification payload.'
29+
)
2330
async with store_lock:
2431
if task_id not in store:
2532
store[task_id] = []

tests/e2e/push_notifications/test_default_push_notification_support.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,6 @@ async def wait_for_n_notifications(
215215
return notifications
216216
if time.time() - start_time > timeout:
217217
raise TimeoutError(
218-
f'Notification retrival timed out. Got {len(notifications)} notifications, want {n}.'
218+
f'Notification retrieval timed out. Got {len(notifications)} notifications, want {n}.'
219219
)
220220
await asyncio.sleep(0.1)

0 commit comments

Comments
 (0)