feat: implement brand-specific configuration and update management for Agravity Bridge
This commit is contained in:
parent
baf56e040f
commit
b988532aaa
9 changed files with 461 additions and 48 deletions
|
|
@ -16,6 +16,17 @@ def update_manager(tmp_path):
|
|||
return UpdateManager(current_version="0.0.1", config_dir=tmp_path)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def agravity_update_manager(tmp_path):
|
||||
"""Create a brand-aware UpdateManager instance for Agravity Bridge."""
|
||||
return UpdateManager(
|
||||
current_version="0.0.1",
|
||||
config_dir=tmp_path,
|
||||
brand_id="agravity",
|
||||
update_channel="stable",
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def sample_release():
|
||||
"""Sample release data from API."""
|
||||
|
|
@ -252,6 +263,109 @@ class TestDownloading:
|
|||
|
||||
assert result is None
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_download_update_uses_release_manifest(self, agravity_update_manager, tmp_path):
|
||||
"""Test branded download selection from a shared release manifest."""
|
||||
release = Release(
|
||||
tag_name="v0.0.2",
|
||||
name="WebDropBridge v0.0.2",
|
||||
version="0.0.2",
|
||||
body="Release notes",
|
||||
assets=[
|
||||
{
|
||||
"name": "AgravityBridge-0.0.2-win-x64.msi",
|
||||
"browser_download_url": "https://example.com/AgravityBridge-0.0.2-win-x64.msi",
|
||||
},
|
||||
{
|
||||
"name": "AgravityBridge-0.0.2-win-x64.msi.sha256",
|
||||
"browser_download_url": "https://example.com/AgravityBridge-0.0.2-win-x64.msi.sha256",
|
||||
},
|
||||
{
|
||||
"name": "OtherBridge-0.0.2-win-x64.msi",
|
||||
"browser_download_url": "https://example.com/OtherBridge-0.0.2-win-x64.msi",
|
||||
},
|
||||
{
|
||||
"name": "release-manifest.json",
|
||||
"browser_download_url": "https://example.com/release-manifest.json",
|
||||
},
|
||||
],
|
||||
published_at="2026-01-29T10:00:00Z",
|
||||
)
|
||||
|
||||
manifest = {
|
||||
"version": "0.0.2",
|
||||
"channel": "stable",
|
||||
"brands": {
|
||||
"agravity": {
|
||||
"windows-x64": {
|
||||
"installer": "AgravityBridge-0.0.2-win-x64.msi",
|
||||
"checksum": "AgravityBridge-0.0.2-win-x64.msi.sha256",
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
with (
|
||||
patch.object(UpdateManager, "_download_json_asset", return_value=manifest),
|
||||
patch.object(UpdateManager, "_download_file", return_value=True) as mock_download,
|
||||
):
|
||||
result = await agravity_update_manager.download_update(release, tmp_path)
|
||||
|
||||
assert result is not None
|
||||
assert result.name == "AgravityBridge-0.0.2-win-x64.msi"
|
||||
mock_download.assert_called_once()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_verify_checksum_uses_release_manifest(self, agravity_update_manager, tmp_path):
|
||||
"""Test branded checksum selection from a shared release manifest."""
|
||||
test_file = tmp_path / "AgravityBridge-0.0.2-win-x64.msi"
|
||||
test_file.write_bytes(b"test content")
|
||||
|
||||
import hashlib
|
||||
|
||||
checksum = hashlib.sha256(b"test content").hexdigest()
|
||||
release = Release(
|
||||
tag_name="v0.0.2",
|
||||
name="WebDropBridge v0.0.2",
|
||||
version="0.0.2",
|
||||
body="Release notes",
|
||||
assets=[
|
||||
{
|
||||
"name": "AgravityBridge-0.0.2-win-x64.msi",
|
||||
"browser_download_url": "https://example.com/AgravityBridge-0.0.2-win-x64.msi",
|
||||
},
|
||||
{
|
||||
"name": "AgravityBridge-0.0.2-win-x64.msi.sha256",
|
||||
"browser_download_url": "https://example.com/AgravityBridge-0.0.2-win-x64.msi.sha256",
|
||||
},
|
||||
{
|
||||
"name": "release-manifest.json",
|
||||
"browser_download_url": "https://example.com/release-manifest.json",
|
||||
},
|
||||
],
|
||||
published_at="2026-01-29T10:00:00Z",
|
||||
)
|
||||
manifest = {
|
||||
"version": "0.0.2",
|
||||
"channel": "stable",
|
||||
"brands": {
|
||||
"agravity": {
|
||||
"windows-x64": {
|
||||
"installer": "AgravityBridge-0.0.2-win-x64.msi",
|
||||
"checksum": "AgravityBridge-0.0.2-win-x64.msi.sha256",
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
with (
|
||||
patch.object(UpdateManager, "_download_json_asset", return_value=manifest),
|
||||
patch.object(UpdateManager, "_download_checksum", return_value=checksum),
|
||||
):
|
||||
result = await agravity_update_manager.verify_checksum(test_file, release)
|
||||
|
||||
assert result is True
|
||||
|
||||
|
||||
class TestChecksumVerification:
|
||||
"""Test checksum verification."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue