feat: 完善版本管理功能 1. 优化使用步骤说明的样式,调整行高和字体大小,提升可读性 2. 新增版本截图 3. 更新依赖包版本 4. 添加版本管理相关文件
This commit is contained in:
63
test_version_manager.py
Normal file
63
test_version_manager.py
Normal file
@@ -0,0 +1,63 @@
|
||||
import logging
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from utils.version_manager import VersionManager
|
||||
|
||||
# 配置日志
|
||||
logging.basicConfig(
|
||||
level=logging.INFO,
|
||||
format='%(asctime)s - %(levelname)s - %(message)s',
|
||||
handlers=[
|
||||
logging.StreamHandler(sys.stdout),
|
||||
logging.FileHandler('version_check.log')
|
||||
]
|
||||
)
|
||||
|
||||
def test_version_manager():
|
||||
"""测试版本管理器功能"""
|
||||
try:
|
||||
vm = VersionManager()
|
||||
logging.info(f"当前版本: {vm.current_version}")
|
||||
logging.info(f"当前平台: {vm.platform}")
|
||||
|
||||
# 测试获取最新版本
|
||||
logging.info("\n=== 测试获取最新版本 ===")
|
||||
latest = vm.get_latest_version()
|
||||
logging.info(f"最新版本信息: {latest}")
|
||||
|
||||
# 测试检查更新
|
||||
logging.info("\n=== 测试检查更新 ===")
|
||||
update_info = vm.check_update()
|
||||
logging.info(f"更新检查结果: {update_info}")
|
||||
|
||||
# 测试是否需要更新
|
||||
logging.info("\n=== 测试是否需要更新 ===")
|
||||
has_update, is_force, version_info = vm.needs_update()
|
||||
logging.info(f"是否有更新: {has_update}")
|
||||
logging.info(f"是否强制更新: {is_force}")
|
||||
logging.info(f"版本信息: {version_info}")
|
||||
|
||||
# 如果有更新,测试下载功能
|
||||
if has_update and version_info:
|
||||
logging.info("\n=== 测试下载更新 ===")
|
||||
download_url = version_info.get('download_url')
|
||||
if download_url:
|
||||
save_path = Path.home() / "Downloads" / "CursorHelper" / "test_update.exe"
|
||||
save_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
logging.info(f"下载地址: {download_url}")
|
||||
logging.info(f"保存路径: {save_path}")
|
||||
|
||||
success = vm.download_update(download_url, str(save_path))
|
||||
logging.info(f"下载结果: {'成功' if success else '失败'}")
|
||||
|
||||
if success:
|
||||
logging.info(f"文件大小: {save_path.stat().st_size} 字节")
|
||||
else:
|
||||
logging.warning("未找到下载地址")
|
||||
|
||||
except Exception as e:
|
||||
logging.error(f"测试过程中发生错误: {str(e)}", exc_info=True)
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_version_manager()
|
||||
Reference in New Issue
Block a user