Don't offer to download latest AppImage unless we are running as an AppImage already
This commit is contained in:
parent
df6ea8d139
commit
757517dcc4
3 changed files with 30 additions and 54 deletions
|
|
@ -6,6 +6,7 @@
|
||||||
* Retain indentation when tab is used to indent a line, unless enter is pressed twice or user deletes the indentation
|
* Retain indentation when tab is used to indent a line, unless enter is pressed twice or user deletes the indentation
|
||||||
* Add missing strings (for English and French)
|
* Add missing strings (for English and French)
|
||||||
* Add 'Last Month' date range for timesheet reports
|
* Add 'Last Month' date range for timesheet reports
|
||||||
|
* Don't offer to download latest AppImage unless we are running as an AppImage already
|
||||||
|
|
||||||
# 0.7.5
|
# 0.7.5
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -95,6 +95,9 @@ class VersionChecker:
|
||||||
"""
|
"""
|
||||||
return self._parse_version(available) > self._parse_version(current)
|
return self._parse_version(available) > self._parse_version(current)
|
||||||
|
|
||||||
|
def _running_in_appimage(self) -> bool:
|
||||||
|
return "APPIMAGE" in os.environ
|
||||||
|
|
||||||
# ---------- Public entrypoint for Help → Version ---------- #
|
# ---------- Public entrypoint for Help → Version ---------- #
|
||||||
|
|
||||||
def show_version_dialog(self) -> None:
|
def show_version_dialog(self) -> None:
|
||||||
|
|
@ -114,8 +117,8 @@ class VersionChecker:
|
||||||
check_button = box.addButton(
|
check_button = box.addButton(
|
||||||
strings._("check_for_updates"), QMessageBox.ActionRole
|
strings._("check_for_updates"), QMessageBox.ActionRole
|
||||||
)
|
)
|
||||||
box.addButton(QMessageBox.Close)
|
|
||||||
|
|
||||||
|
box.addButton(QMessageBox.Close)
|
||||||
box.exec()
|
box.exec()
|
||||||
|
|
||||||
if box.clickedButton() is check_button:
|
if box.clickedButton() is check_button:
|
||||||
|
|
@ -159,21 +162,32 @@ class VersionChecker:
|
||||||
return
|
return
|
||||||
|
|
||||||
# Newer version is available
|
# Newer version is available
|
||||||
reply = QMessageBox.question(
|
|
||||||
self._parent,
|
|
||||||
strings._("update"),
|
|
||||||
(
|
|
||||||
strings._("there_is_a_new_version_available")
|
|
||||||
+ available_raw
|
|
||||||
+ "\n\n"
|
|
||||||
+ strings._("download_the_appimage")
|
|
||||||
),
|
|
||||||
QMessageBox.Yes | QMessageBox.No,
|
|
||||||
)
|
|
||||||
if reply != QMessageBox.Yes:
|
|
||||||
return
|
|
||||||
|
|
||||||
self._download_and_verify_appimage(available_raw)
|
if self._running_in_appimage():
|
||||||
|
# If running in an AppImage, offer to download the new AppImage
|
||||||
|
reply = QMessageBox.question(
|
||||||
|
self._parent,
|
||||||
|
strings._("update"),
|
||||||
|
(
|
||||||
|
strings._("there_is_a_new_version_available")
|
||||||
|
+ available_raw
|
||||||
|
+ "\n\n"
|
||||||
|
+ strings._("download_the_appimage")
|
||||||
|
),
|
||||||
|
QMessageBox.Yes | QMessageBox.No,
|
||||||
|
)
|
||||||
|
if reply != QMessageBox.Yes:
|
||||||
|
return
|
||||||
|
|
||||||
|
self._download_and_verify_appimage(available_raw)
|
||||||
|
else:
|
||||||
|
# If not running in an AppImage, just report that there's a new version.
|
||||||
|
QMessageBox.information(
|
||||||
|
self._parent,
|
||||||
|
strings._("update"),
|
||||||
|
(strings._("there_is_a_new_version_available") + available_raw),
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
# ---------- Download + verification helpers ---------- #
|
# ---------- Download + verification helpers ---------- #
|
||||||
def _download_file(
|
def _download_file(
|
||||||
|
|
|
||||||
|
|
@ -173,45 +173,6 @@ def test_check_for_updates_already_latest(qtbot, app):
|
||||||
assert mock_info.called
|
assert mock_info.called
|
||||||
|
|
||||||
|
|
||||||
def test_check_for_updates_new_version_available_declined(qtbot, app):
|
|
||||||
"""Test check for updates when new version is available but user declines."""
|
|
||||||
parent = QWidget()
|
|
||||||
qtbot.addWidget(parent)
|
|
||||||
checker = VersionChecker(parent)
|
|
||||||
|
|
||||||
mock_response = Mock()
|
|
||||||
mock_response.text = "2.0.0"
|
|
||||||
mock_response.raise_for_status = Mock()
|
|
||||||
|
|
||||||
with patch("requests.get", return_value=mock_response):
|
|
||||||
with patch("importlib.metadata.version", return_value="1.0.0"):
|
|
||||||
with patch.object(QMessageBox, "question", return_value=QMessageBox.No):
|
|
||||||
# Should not proceed to download
|
|
||||||
checker.check_for_updates()
|
|
||||||
|
|
||||||
|
|
||||||
def test_check_for_updates_new_version_available_accepted(qtbot, app):
|
|
||||||
"""Test check for updates when new version is available and user accepts."""
|
|
||||||
parent = QWidget()
|
|
||||||
qtbot.addWidget(parent)
|
|
||||||
checker = VersionChecker(parent)
|
|
||||||
|
|
||||||
mock_response = Mock()
|
|
||||||
mock_response.text = "2.0.0"
|
|
||||||
mock_response.raise_for_status = Mock()
|
|
||||||
|
|
||||||
with patch("requests.get", return_value=mock_response):
|
|
||||||
with patch("importlib.metadata.version", return_value="1.0.0"):
|
|
||||||
with patch.object(QMessageBox, "question", return_value=QMessageBox.Yes):
|
|
||||||
with patch.object(
|
|
||||||
checker, "_download_and_verify_appimage"
|
|
||||||
) as mock_download:
|
|
||||||
checker.check_for_updates()
|
|
||||||
|
|
||||||
# Should call download
|
|
||||||
mock_download.assert_called_once_with("2.0.0")
|
|
||||||
|
|
||||||
|
|
||||||
def test_download_file_success(qtbot, app, tmp_path):
|
def test_download_file_success(qtbot, app, tmp_path):
|
||||||
"""Test downloading a file successfully."""
|
"""Test downloading a file successfully."""
|
||||||
checker = VersionChecker()
|
checker = VersionChecker()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue