Skip to content

Commit bc91902

Browse files
committed
style: apply ruff formatting to test files
1 parent 1adb6e2 commit bc91902

File tree

3 files changed

+42
-22
lines changed

3 files changed

+42
-22
lines changed

tests/server/test_models.py

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ def test_process_bind_param_with_pydantic_model(self):
2222
dialect = MagicMock()
2323

2424
result = pydantic_type.process_bind_param(status, dialect)
25-
assert result["state"] == "working"
26-
assert result["message"] is None
25+
assert result['state'] == 'working'
26+
assert result['message'] is None
2727
# TaskStatus may have other optional fields
2828

2929
def test_process_bind_param_with_none(self):
@@ -37,9 +37,11 @@ def test_process_result_value(self):
3737
pydantic_type = PydanticType(TaskStatus)
3838
dialect = MagicMock()
3939

40-
result = pydantic_type.process_result_value({"state": "completed", "message": None}, dialect)
40+
result = pydantic_type.process_result_value(
41+
{'state': 'completed', 'message': None}, dialect
42+
)
4143
assert isinstance(result, TaskStatus)
42-
assert result.state == "completed"
44+
assert result.state == 'completed'
4345

4446

4547
class TestPydanticListType:
@@ -48,33 +50,38 @@ class TestPydanticListType:
4850
def test_process_bind_param_with_list(self):
4951
pydantic_list_type = PydanticListType(Artifact)
5052
artifacts = [
51-
Artifact(artifact_id="1", parts=[TextPart(type="text", text="Hello")]),
52-
Artifact(artifact_id="2", parts=[TextPart(type="text", text="World")])
53+
Artifact(
54+
artifact_id='1', parts=[TextPart(type='text', text='Hello')]
55+
),
56+
Artifact(
57+
artifact_id='2', parts=[TextPart(type='text', text='World')]
58+
),
5359
]
5460
dialect = MagicMock()
5561

5662
result = pydantic_list_type.process_bind_param(artifacts, dialect)
5763
assert len(result) == 2
58-
assert result[0]["artifactId"] == "1" # JSON mode uses camelCase
59-
assert result[1]["artifactId"] == "2"
64+
assert result[0]['artifactId'] == '1' # JSON mode uses camelCase
65+
assert result[1]['artifactId'] == '2'
6066

6167
def test_process_result_value_with_list(self):
6268
pydantic_list_type = PydanticListType(Artifact)
6369
dialect = MagicMock()
6470
data = [
65-
{"artifact_id": "1", "parts": [{"type": "text", "text": "Hello"}]},
66-
{"artifact_id": "2", "parts": [{"type": "text", "text": "World"}]}
71+
{'artifact_id': '1', 'parts': [{'type': 'text', 'text': 'Hello'}]},
72+
{'artifact_id': '2', 'parts': [{'type': 'text', 'text': 'World'}]},
6773
]
6874

6975
result = pydantic_list_type.process_result_value(data, dialect)
7076
assert len(result) == 2
7177
assert all(isinstance(art, Artifact) for art in result)
72-
assert result[0].artifact_id == "1"
73-
assert result[1].artifact_id == "2"
78+
assert result[0].artifact_id == '1'
79+
assert result[1].artifact_id == '2'
7480

7581

7682
def test_create_task_model():
7783
"""Test dynamic task model creation."""
84+
7885
# Create a fresh base to avoid table conflicts
7986
class TestBase(DeclarativeBase):
8087
pass
@@ -92,15 +99,20 @@ class TestBase(DeclarativeBase):
9299

93100
def test_create_push_notification_config_model():
94101
"""Test dynamic push notification config model creation."""
102+
95103
# Create a fresh base to avoid table conflicts
96104
class TestBase(DeclarativeBase):
97105
pass
98106

99107
# Create with default table name
100-
default_model = create_push_notification_config_model('test_push_configs_1', TestBase)
108+
default_model = create_push_notification_config_model(
109+
'test_push_configs_1', TestBase
110+
)
101111
assert default_model.__tablename__ == 'test_push_configs_1'
102112

103113
# Create with custom table name
104-
custom_model = create_push_notification_config_model('test_push_configs_2', TestBase)
114+
custom_model = create_push_notification_config_model(
115+
'test_push_configs_2', TestBase
116+
)
105117
assert custom_model.__tablename__ == 'test_push_configs_2'
106118
assert 'test_push_configs_2' in custom_model.__name__

tests/utils/test_constants.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,15 @@
55

66
def test_agent_card_constants():
77
"""Test that agent card constants have expected values."""
8-
assert constants.AGENT_CARD_WELL_KNOWN_PATH == '/.well-known/agent-card.json'
9-
assert constants.PREV_AGENT_CARD_WELL_KNOWN_PATH == '/.well-known/agent.json'
10-
assert constants.EXTENDED_AGENT_CARD_PATH == '/agent/authenticatedExtendedCard'
8+
assert (
9+
constants.AGENT_CARD_WELL_KNOWN_PATH == '/.well-known/agent-card.json'
10+
)
11+
assert (
12+
constants.PREV_AGENT_CARD_WELL_KNOWN_PATH == '/.well-known/agent.json'
13+
)
14+
assert (
15+
constants.EXTENDED_AGENT_CARD_PATH == '/agent/authenticatedExtendedCard'
16+
)
1117

1218

1319
def test_default_rpc_url():

tests/utils/test_error_handlers.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def __init__(self, content, status_code):
2727
@pytest.mark.asyncio
2828
async def test_rest_error_handler_server_error():
2929
"""Test rest_error_handler with ServerError."""
30-
error = InvalidRequestError(message="Bad request")
30+
error = InvalidRequestError(message='Bad request')
3131

3232
@rest_error_handler
3333
async def failing_func():
@@ -44,9 +44,10 @@ async def failing_func():
4444
@pytest.mark.asyncio
4545
async def test_rest_error_handler_unknown_exception():
4646
"""Test rest_error_handler with unknown exception."""
47+
4748
@rest_error_handler
4849
async def failing_func():
49-
raise ValueError("Unexpected error")
50+
raise ValueError('Unexpected error')
5051

5152
with patch('a2a.utils.error_handlers.JSONResponse', MockJSONResponse):
5253
result = await failing_func()
@@ -59,7 +60,7 @@ async def failing_func():
5960
@pytest.mark.asyncio
6061
async def test_rest_stream_error_handler_server_error():
6162
"""Test rest_stream_error_handler with ServerError."""
62-
error = InternalError(message="Internal server error")
63+
error = InternalError(message='Internal server error')
6364

6465
@rest_stream_error_handler
6566
async def failing_stream():
@@ -74,11 +75,12 @@ async def failing_stream():
7475
@pytest.mark.asyncio
7576
async def test_rest_stream_error_handler_reraises_exception():
7677
"""Test rest_stream_error_handler reraises other exceptions."""
78+
7779
@rest_stream_error_handler
7880
async def failing_stream():
79-
raise RuntimeError("Stream failed")
81+
raise RuntimeError('Stream failed')
8082

81-
with pytest.raises(RuntimeError, match="Stream failed"):
83+
with pytest.raises(RuntimeError, match='Stream failed'):
8284
await failing_stream()
8385

8486

0 commit comments

Comments
 (0)