fix(update): accept cmhub release metadata contract
This commit is contained in:
@@ -1747,9 +1747,6 @@ class GuiTests(TempDirMixin, unittest.TestCase):
|
||||
"latest_version": "1.2.0",
|
||||
"sha256": "a" * 64,
|
||||
"size_bytes": 100,
|
||||
"package_format": "cmshopee-portable-v1",
|
||||
"updater_protocol": 1,
|
||||
"min_updater_protocol": 1,
|
||||
}
|
||||
http_dialog = ForcedUpdateDialog(
|
||||
update_check.UpdateCheckResult(
|
||||
|
||||
@@ -92,6 +92,34 @@ class UpdateCheckTests(unittest.TestCase):
|
||||
self.assertEqual("abc", result.sha256)
|
||||
self.assertEqual("新版说明", result.message)
|
||||
|
||||
def test_check_for_update_accepts_cmhub_release_contract(self):
|
||||
def fetcher(_url, _timeout):
|
||||
return {
|
||||
"platform": "windows",
|
||||
"release": {
|
||||
"version": "0.1.6",
|
||||
"download_url": "http://185.216.248.75:24521/down/release.zip",
|
||||
"sha256": "a" * 64,
|
||||
"release_notes": "启动时联网获取更新信息",
|
||||
"force_update": True,
|
||||
"size_bytes": 53318076,
|
||||
"published_at": "2026-07-13T17:10:59.660653+08:00",
|
||||
},
|
||||
}
|
||||
|
||||
result = update_check.check_for_update(
|
||||
current_version="0.1.5",
|
||||
url="https://cm.example.test/api/v1/client/releases/latest?platform=windows",
|
||||
fetcher=fetcher,
|
||||
)
|
||||
|
||||
self.assertTrue(result.forced)
|
||||
self.assertFalse(result.can_enter)
|
||||
self.assertEqual("0.1.6", result.latest_version)
|
||||
self.assertEqual(53318076, result.size_bytes)
|
||||
self.assertEqual("", result.package_format)
|
||||
self.assertEqual(0, result.updater_protocol)
|
||||
|
||||
def test_network_failure_allows_entry(self):
|
||||
def fetcher(_url, _timeout):
|
||||
raise socket.timeout("timeout")
|
||||
|
||||
@@ -6,6 +6,7 @@ import unittest
|
||||
import urllib.request
|
||||
import zipfile
|
||||
from pathlib import Path
|
||||
from types import SimpleNamespace
|
||||
|
||||
from app import release_manifest, update_installer
|
||||
|
||||
@@ -71,6 +72,20 @@ class UpdateInstallerTests(unittest.TestCase):
|
||||
values.update(changes)
|
||||
return update_installer.UpdatePackageMetadata(**values)
|
||||
|
||||
def test_online_release_uses_internal_package_contract_defaults(self):
|
||||
info = SimpleNamespace(
|
||||
latest_version="0.1.6",
|
||||
download_url="http://downloads.external.test/cmshopee.zip",
|
||||
sha256="a" * 64,
|
||||
size_bytes=53318076,
|
||||
)
|
||||
|
||||
metadata = update_installer.metadata_from_update_info(info)
|
||||
|
||||
self.assertEqual(release_manifest.PACKAGE_FORMAT, metadata.package_format)
|
||||
self.assertEqual(release_manifest.UPDATER_PROTOCOL, metadata.updater_protocol)
|
||||
self.assertEqual(release_manifest.UPDATER_PROTOCOL, metadata.min_updater_protocol)
|
||||
|
||||
def test_prepare_update_verifies_and_reuses_pending(self):
|
||||
with tempfile.TemporaryDirectory() as temp_dir:
|
||||
payload = self.make_zip(temp_dir)
|
||||
|
||||
Reference in New Issue
Block a user