Source installs look up releases on the Gitea repository (git.bongbetic.com/xavierk/voculinux) through its JSON API and parse tag_name, html_url and body. The GitHub API and the HTML scrape fallback are removed, and only that Gitea repository's release pages are trusted links. Packaged installs (the xbps marker) make no release request at all: fetch_latest_release returns before importing requests, and Settings -> About shows that updates arrive via sudo xbps-install -Su. Refs #16, #27
94 lines
3.5 KiB
Python
94 lines
3.5 KiB
Python
"""Unit guards for packaged-install detection and its update presentation.
|
|
|
|
Ticket #27 decides the update-checker behaviour for packaged installs:
|
|
background checks stay available as a signal, but every user-visible
|
|
update affordance presents the package-manager path instead of release
|
|
downloads. The xbps template installs the marker this module reads.
|
|
"""
|
|
|
|
from pathlib import Path
|
|
|
|
from vocalinux.utils.packaging import (
|
|
PACKAGED_MARKER_PATH,
|
|
PACKAGED_UPDATE_HINT,
|
|
is_packaged_install,
|
|
update_menu_label,
|
|
update_menu_tooltip,
|
|
update_notification_body,
|
|
updates_description,
|
|
)
|
|
|
|
|
|
def test_default_marker_lives_under_the_renamed_share_dir() -> None:
|
|
"""The template installs usr/share/voculinux/packaged; the code reads it."""
|
|
assert PACKAGED_MARKER_PATH == Path("/usr/share/voculinux/packaged")
|
|
|
|
|
|
def test_unpackaged_install_by_default(tmp_path: Path) -> None:
|
|
"""No marker in the test environment means a non-packaged install."""
|
|
assert not is_packaged_install(marker=tmp_path / "packaged")
|
|
|
|
|
|
def test_packaged_install_when_the_marker_exists(tmp_path: Path) -> None:
|
|
"""The xbps template drops the marker file at install time."""
|
|
marker = tmp_path / "packaged"
|
|
marker.touch()
|
|
assert is_packaged_install(marker=marker)
|
|
|
|
|
|
def test_packaged_hint_names_the_package_manager_path() -> None:
|
|
"""The presented path is xbps, not a release download."""
|
|
assert "xbps-install -Su" in PACKAGED_UPDATE_HINT
|
|
assert "updates arrive via sudo xbps-install -Su" in PACKAGED_UPDATE_HINT
|
|
|
|
|
|
def test_unpackaged_menu_label_is_unchanged() -> None:
|
|
"""Source installs keep the release-download affordance they always had."""
|
|
assert update_menu_label("v1.2.3", packaged=False) == "Update Available (v1.2.3)…"
|
|
|
|
|
|
def test_packaged_menu_label_presents_the_package_manager() -> None:
|
|
"""Packaged installs must not misdirect users to release downloads."""
|
|
label = update_menu_label("v1.2.3", packaged=True)
|
|
assert "v1.2.3" in label
|
|
assert "package manager" in label
|
|
|
|
|
|
def test_unpackaged_menu_tooltip_is_unchanged() -> None:
|
|
"""Source installs keep pointing at release notes and download links."""
|
|
tooltip = update_menu_tooltip(packaged=False)
|
|
assert "release notes" in tooltip and "download links" in tooltip
|
|
|
|
|
|
def test_packaged_menu_tooltip_names_xbps() -> None:
|
|
"""The packaged tooltip tells the user where the update comes from."""
|
|
assert "xbps" in update_menu_tooltip(packaged=True)
|
|
|
|
|
|
def test_packaged_notification_body_presents_the_package_manager() -> None:
|
|
"""The desktop notification must not offer a download path either."""
|
|
body = update_notification_body("v1.2.3", packaged=True)
|
|
assert "v1.2.3" in body
|
|
assert "package manager" in body
|
|
|
|
|
|
def test_unpackaged_notification_body_keeps_release_notes() -> None:
|
|
"""Source installs keep the existing notification wording."""
|
|
body = update_notification_body("v1.2.3", packaged=False)
|
|
assert "v1.2.3" in body
|
|
assert "release notes" in body
|
|
|
|
|
|
def test_unpackaged_updates_description_is_unchanged() -> None:
|
|
"""The About page keeps its channel wording for source installs."""
|
|
description = updates_description("stable", packaged=False)
|
|
assert "stable" in description
|
|
assert "package manager" not in description
|
|
|
|
|
|
def test_packaged_updates_description_presents_the_package_manager() -> None:
|
|
"""The About page tells packaged users to update through xbps."""
|
|
description = updates_description("stable", packaged=True)
|
|
assert "stable" in description
|
|
assert "xbps-install -Su" in description
|