Skip to content

Commit af84846

Browse files
committed
format
1 parent 93e7f76 commit af84846

3 files changed

Lines changed: 58 additions & 30 deletions

File tree

tests/realtime/test_live.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414

1515
import pytest
16-
from unittest.mock import AsyncMock, MagicMock
16+
from unittest.mock import AsyncMock, MagicMock, patch
1717
from veadk.realtime.live import DoubaoAsyncSession, ProtocolEvents
1818
from veadk.realtime import protocol
1919
from google.genai import types
@@ -111,21 +111,22 @@ async def test_receive(mock_session):
111111

112112
for response_data, parse_data, expected in test_cases:
113113
mock_session._ws.recv = AsyncMock(return_value=response_data)
114-
protocol.parse_response = MagicMock(return_value=parse_data)
115-
async for msg in mock_session.receive():
116-
if response_data["event"] == ProtocolEvents.ASR_INFO:
117-
assert msg.server_content.interrupted == expected
118-
elif response_data["event"] == ProtocolEvents.ASR_RESPONSE:
119-
assert msg.server_content.input_transcription.text == expected
120-
elif response_data["event"] == ProtocolEvents.TTS_RESPONSE:
121-
assert (
122-
msg.server_content.model_turn.parts[0].inline_data.data == expected
123-
)
124-
elif response_data["event"] == ProtocolEvents.CHAT_RESPONSE:
125-
assert msg.server_content.output_transcription.text == expected
126-
elif response_data["event"] == ProtocolEvents.USAGE_RESPONSE:
127-
assert msg.usage_metadata.tool_use_prompt_token_count == expected
128-
break
114+
with patch.object(protocol, "parse_response", return_value=parse_data):
115+
async for msg in mock_session.receive():
116+
if response_data["event"] == ProtocolEvents.ASR_INFO:
117+
assert msg.server_content.interrupted == expected
118+
elif response_data["event"] == ProtocolEvents.ASR_RESPONSE:
119+
assert msg.server_content.input_transcription.text == expected
120+
elif response_data["event"] == ProtocolEvents.TTS_RESPONSE:
121+
assert (
122+
msg.server_content.model_turn.parts[0].inline_data.data
123+
== expected
124+
)
125+
elif response_data["event"] == ProtocolEvents.CHAT_RESPONSE:
126+
assert msg.server_content.output_transcription.text == expected
127+
elif response_data["event"] == ProtocolEvents.USAGE_RESPONSE:
128+
assert msg.usage_metadata.tool_use_prompt_token_count == expected
129+
break
129130

130131

131132
@pytest.mark.asyncio

tests/test_agent.py

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414

1515
import os
16-
from unittest.mock import Mock, patch
16+
from unittest.mock import Mock, PropertyMock, patch
1717

1818
from google.adk.agents.llm_agent import LlmAgent
1919
from google.adk.models.lite_llm import LiteLlm
@@ -76,19 +76,32 @@ def test_agent():
7676

7777
@patch.dict("os.environ", {"MODEL_AGENT_API_KEY": "mock_api_key"})
7878
def test_agent_default_values():
79-
agent = Agent()
80-
81-
assert agent.name == DEFAULT_AGENT_NAME
82-
83-
assert agent.model_name == DEFAULT_MODEL_AGENT_NAME
84-
assert agent.model_provider == DEFAULT_MODEL_AGENT_PROVIDER
85-
assert agent.model_api_base == DEFAULT_MODEL_AGENT_API_BASE
86-
87-
assert agent.tools == []
88-
assert agent.sub_agents == []
89-
assert agent.knowledgebase is None
90-
assert agent.long_term_memory is None
91-
# assert agent.tracers == []
79+
with (
80+
patch("veadk.agent.settings.model.name", new=DEFAULT_MODEL_AGENT_NAME),
81+
patch("veadk.agent.settings.model.provider", new=DEFAULT_MODEL_AGENT_PROVIDER),
82+
patch(
83+
"veadk.agent.settings.model.api_base",
84+
new=DEFAULT_MODEL_AGENT_API_BASE,
85+
),
86+
patch(
87+
"veadk.configs.model_configs.ModelConfig.api_key",
88+
new_callable=PropertyMock,
89+
return_value="mock_api_key",
90+
),
91+
):
92+
agent = Agent()
93+
94+
assert agent.name == DEFAULT_AGENT_NAME
95+
96+
assert agent.model_name == DEFAULT_MODEL_AGENT_NAME
97+
assert agent.model_provider == DEFAULT_MODEL_AGENT_PROVIDER
98+
assert agent.model_api_base == DEFAULT_MODEL_AGENT_API_BASE
99+
100+
assert agent.tools == []
101+
assert agent.sub_agents == []
102+
assert agent.knowledgebase is None
103+
assert agent.long_term_memory is None
104+
# assert agent.tracers == []
92105

93106

94107
@patch.dict("os.environ", {"MODEL_AGENT_API_KEY": "mock_api_key"})

tests/test_feishu_channel_extension.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# Copyright (c) 2025 Beijing Volcano Engine Technology Co., Ltd. and/or its affiliates.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
115
from types import SimpleNamespace
216

317
import pytest

0 commit comments

Comments
 (0)