add youtube tool

This commit is contained in:
xmhu2001
2025-07-13 00:02:08 +08:00
parent 45ded8f467
commit 5292c383d4
3 changed files with 268 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
#!/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time : 2025/7/12 23:00
# @Author : xmhu2001
# @Email : xmhu2001@qq.com
# @FileName: test_youtube_tool.py
import unittest
import os
from agentuniverse.agent.action.tool.common_tool.youtube_tool import YouTubeTool, Mode
from agentuniverse.agent.action.tool.tool import ToolInput
class YouTubeToolTest(unittest.TestCase):
"""
Test cases for YouTubeTool class
"""
def setUp(self) -> None:
self.tool = YouTubeTool()
def test_search_videos(self) -> None:
tool_input = ToolInput({
'mode': Mode.VIDEO_SEARCH.value,
'input': 'machine learning'
})
result = self.tool.execute(tool_input.mode, tool_input.input)
self.assertTrue(result != [])
def test_analyze_channel(self) -> None:
tool_input = ToolInput({
'mode': Mode.CHANNEL_ANALYZE.value,
'input': 'UC_x5XG1OV2P6uZZ5FSM9Ttw'
})
result = self.tool.execute(tool_input.mode, tool_input.input)
self.assertTrue(result != {})
def test_get_trending_videos_with_region(self) -> None:
tool_input = ToolInput({
'mode': Mode.TRENDING_VIDEOS.value,
'input': 'US'
})
result = self.tool.execute(tool_input.mode, tool_input.input)
self.assertTrue(result != [])
def test_get_trending_videos(self) -> None:
tool_input = ToolInput({
'mode': Mode.TRENDING_VIDEOS.value
})
result = self.tool.execute(mode=tool_input.mode)
self.assertTrue(result != [])
if __name__ == '__main__':
unittest.main()