Skip to content

Commit 72a1b43

Browse files
committed
Add tests for camelCase removal
1 parent 941a8d5 commit 72a1b43

File tree

1 file changed

+27
-13
lines changed

1 file changed

+27
-13
lines changed

tests/test_types.py

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1530,7 +1530,11 @@ def test_use_get_task_push_notification_params_for_request() -> None:
15301530
)
15311531

15321532

1533-
def test_camelCase() -> None:
1533+
def test_camelCase_access_raises_attribute_error() -> None:
1534+
"""
1535+
Tests that accessing or setting fields via their camelCase alias
1536+
raises an AttributeError.
1537+
"""
15341538
skill = AgentSkill(
15351539
id='hello_world',
15361540
name='Returns hello world',
@@ -1539,6 +1543,7 @@ def test_camelCase() -> None:
15391543
examples=['hi', 'hello world'],
15401544
)
15411545

1546+
# Initialization with camelCase still works due to Pydantic's populate_by_name config
15421547
agent_card = AgentCard(
15431548
name='Hello World Agent',
15441549
description='Just a hello world agent',
@@ -1551,22 +1556,31 @@ def test_camelCase() -> None:
15511556
supportsAuthenticatedExtendedCard=True,
15521557
)
15531558

1554-
# Test setting an attribute via camelCase alias
1555-
# We expect a DeprecationWarning with a specific message
1556-
with pytest.warns(
1557-
DeprecationWarning,
1558-
match="Setting field 'supportsAuthenticatedExtendedCard'",
1559+
# --- Test that using camelCase aliases raises errors ---
1560+
1561+
# Test setting an attribute via camelCase alias raises AttributeError
1562+
with pytest.raises(
1563+
AttributeError,
1564+
match="Setting field 'supportsAuthenticatedExtendedCard' via its camelCase alias is not allowed. Use the snake_case name 'supports_authenticated_extended_card' instead.",
15591565
):
15601566
agent_card.supportsAuthenticatedExtendedCard = False
15611567

1562-
# Test getting an attribute via camelCase alias
1563-
# We expect another DeprecationWarning with a specific message
1564-
with pytest.warns(
1565-
DeprecationWarning, match="Accessing field 'defaultInputModes'"
1568+
# Test getting an attribute via camelCase alias raises AttributeError
1569+
with pytest.raises(
1570+
AttributeError,
1571+
match="Accessing field 'defaultInputModes' via its camelCase alias is not allowed. Use the snake_case name 'default_input_modes' instead.",
15661572
):
1567-
default_input_modes = agent_card.defaultInputModes
1573+
_ = agent_card.defaultInputModes
15681574

1569-
# Assert the functionality still works as expected
1575+
# --- Test that using snake_case names works correctly ---
1576+
1577+
# The value should be unchanged because the camelCase setattr failed
1578+
assert agent_card.supports_authenticated_extended_card is True
1579+
1580+
# Now, set it correctly using the snake_case name
1581+
agent_card.supports_authenticated_extended_card = False
15701582
assert agent_card.supports_authenticated_extended_card is False
1583+
1584+
# Get the attribute correctly using the snake_case name
1585+
default_input_modes = agent_card.default_input_modes
15711586
assert default_input_modes == ['text']
1572-
assert agent_card.default_input_modes == ['text']

0 commit comments

Comments
 (0)