Skip to content

Commit d7304ea

Browse files
plutolessclaude
andcommitted
test: align vendor construction with typed pydantic constructors (mypy)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 38619a7 commit d7304ea

3 files changed

Lines changed: 13 additions & 12 deletions

File tree

tests/custom/test_agentkit_vendors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def test_anam_avatar_serializes_avatar_id() -> None:
8989

9090
def test_anam_avatar_requires_avatar_id() -> None:
9191
with pytest.raises(ValidationError):
92-
AnamAvatar(api_key="anam-key")
92+
AnamAvatar(api_key="anam-key") # type: ignore[call-arg]
9393

9494

9595
def test_vertex_ai_explicit_fields_override_additional_params():

tests/custom/test_sensetime_avatar.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ def _scene_list() -> List[Dict[str, Any]]:
4242

4343
def test_sensetime_avatar_accepts_snake_case() -> None:
4444
from agora_agent.agentkit.vendors.cn import SenseTimeAvatar
45-
camel = SenseTimeAvatar(agora_uid="2", appId="app", app_key="key").to_config()
4645
snake = SenseTimeAvatar(agora_uid="2", app_id="app", app_key="key").to_config()
46+
camel = SenseTimeAvatar(**{"agora_uid": "2", "appId": "app", "app_key": "key"}).to_config()
4747
assert camel == snake
4848
assert snake["params"]["appId"] == "app"
4949

@@ -52,9 +52,9 @@ def test_sensetime_avatar_to_config_shape() -> None:
5252
config = SenseTimeAvatar(
5353
agora_token="avatar-token",
5454
agora_uid="2",
55-
appId="sensetime-app-id",
55+
app_id="sensetime-app-id",
5656
app_key="sensetime-app-key",
57-
sceneList=_scene_list(),
57+
scene_list=_scene_list(),
5858
).to_config()
5959

6060
assert config == {
@@ -75,7 +75,7 @@ def test_sensetime_avatar_to_config_omits_token_when_not_provided() -> None:
7575
config = SenseTimeAvatar(
7676
agora_uid="2",
7777
app_key="sensetime-app-key",
78-
sceneList=_scene_list(),
78+
scene_list=_scene_list(),
7979
).to_config()
8080

8181
assert "agora_token" not in config["params"]
@@ -142,7 +142,7 @@ def test_sensetime_avatar_session_validation_and_token_passthrough() -> None:
142142
agora_token="avatar-token",
143143
agora_uid="2",
144144
app_key="sensetime-app-key",
145-
sceneList=_scene_list(),
145+
scene_list=_scene_list(),
146146
)
147147
)
148148
session = _session(agent)
@@ -164,7 +164,7 @@ def test_sensetime_avatar_enrichment_generates_token() -> None:
164164
SenseTimeAvatar(
165165
agora_uid="2",
166166
app_key="sensetime-app-key",
167-
sceneList=_scene_list(),
167+
scene_list=_scene_list(),
168168
)
169169
)
170170
session = _session(agent)
@@ -187,7 +187,7 @@ def test_sensetime_avatar_user_token_is_not_overwritten() -> None:
187187
agora_uid="2",
188188
agora_token="user-token",
189189
app_key="sensetime-app-key",
190-
sceneList=_scene_list(),
190+
scene_list=_scene_list(),
191191
)
192192
)
193193
session = _session(agent)

tests/custom/test_vendor_collapse_golden.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,10 @@ def test_aliyun_llm_pins_vendor_golden() -> None:
8585

8686

8787
def test_sensetime_avatar_camelcase_golden() -> None:
88-
# SenseTimeAvatarOptions uses alias "appId" for the app_id field;
89-
# pydantic v2 requires the alias keyword in the constructor.
90-
cfg = SenseTimeAvatar(agora_uid="2", appId="app", app_key="key").to_config()
88+
# Verifies that the camelCase alias "appId" still works as constructor input
89+
# (populate_by_name=True means both the field name and alias are accepted at runtime).
90+
# Dict-unpack is used so mypy does not call-arg-check the alias keyword.
91+
cfg = SenseTimeAvatar(**{"agora_uid": "2", "appId": "app", "app_key": "key"}).to_config()
9192
assert cfg["vendor"] == "sensetime"
9293
assert cfg["params"]["appId"] == "app"
9394

@@ -104,5 +105,5 @@ def test_fengming_rejects_kwargs() -> None:
104105
import pytest
105106
from pydantic import ValidationError
106107
with pytest.raises(ValidationError):
107-
FengmingSTT(unexpected="x")
108+
FengmingSTT(unexpected="x") # type: ignore[call-arg]
108109
assert FengmingSTT().to_config() == {"vendor": "fengming"}

0 commit comments

Comments
 (0)