mirror of
https://gitee.com/wanwujie/deer-flow
synced 2026-04-24 14:44:46 +08:00
test: add more unit tests of tools (#315)
* test: add more test on test_tts.py * test: add unit test of search and retriever in tools * test: remove the main code of search.py * test: add the travily_search unit test * reformate the codes * test: add unit tests of tools * Added the pytest-asyncio dependency * added the license header of test_tavily_search_api_wrapper.py
This commit is contained in:
@@ -229,3 +229,20 @@ class TestVolcengineTTS:
|
||||
args, kwargs = mock_post.call_args
|
||||
request_json = json.loads(args[1])
|
||||
assert request_json["user"]["uid"] == str(mock_uuid_value)
|
||||
|
||||
@patch("src.tools.tts.requests.post")
|
||||
def test_text_to_speech_request_exception(self, mock_post):
|
||||
"""Test error handling when requests.post raises an exception."""
|
||||
# Mock requests.post to raise an exception
|
||||
mock_post.side_effect = Exception("Network error")
|
||||
# Create TTS client
|
||||
tts = VolcengineTTS(
|
||||
appid="test_appid",
|
||||
access_token="test_token",
|
||||
)
|
||||
# Call the method
|
||||
result = tts.text_to_speech("Hello, world!")
|
||||
# Verify the result
|
||||
assert result["success"] is False
|
||||
assert result["error"] == "Network error"
|
||||
assert result["audio_data"] is None
|
||||
|
||||
Reference in New Issue
Block a user