| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- """
- 测试脚本:验证 sync_play_video 方法修复是否成功
- """
- import sys
- import os
- # 添加项目根目录到 Python 路径
- current_dir = os.path.dirname(os.path.abspath(__file__))
- sys.path.append(current_dir)
- from kodi_util.kodi_server import KodiServer
- def test_sync_play_video():
- """测试 sync_play_video 方法"""
- print("开始测试 sync_play_video 方法...")
-
- try:
- # 创建 KodiServer 实例
- kodi_server = KodiServer()
- print("KodiServer 实例创建成功")
-
- # 测试调用 sync_play_video 方法(使用支持的参数)
- result = kodi_server.sync_play_video(
- video_path="/test/video.mp4",
- sound_client_index=0,
- default_volume=70
- )
- print(f"sync_play_video 调用成功,结果: {result}")
-
- # 测试调用时不传入不支持的参数
- print("测试通过:sync_play_video 方法可以正常调用,不会出现参数错误")
- return True
-
- except TypeError as e:
- if "unexpected keyword argument" in str(e):
- print(f"测试失败:仍然存在不支持的参数错误 - {str(e)}")
- return False
- else:
- print(f"其他类型错误(可能是正常的): {str(e)}")
- return True
- except Exception as e:
- print(f"其他异常(可能是正常的,因为没有真实的 Kodi 客户端): {str(e)}")
- return True
- if __name__ == "__main__":
- success = test_sync_play_video()
- if success:
- print("\n✅ 修复成功!sync_play_video 方法现在可以正常工作了。")
- else:
- print("\n❌ 修复失败!仍然存在参数错误。")
-
- sys.exit(0 if success else 1)
|