Skip to content

Commit

Permalink
fix: Remove confusing Notification regarding System updates (#128)
Browse files Browse the repository at this point in the history
  • Loading branch information
gerblesh authored Sep 1, 2024
2 parents f00bb4a + d3123c0 commit dce31e5
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/ublue_update/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,13 @@ def run_updates(system, system_update_available):
transaction_wait()

if process_uid == 0:
notify(
"System Updater",
"System passed checks, updating ...",
)
if system_update_available:
# Notify about a full system update but not about only
# distrobox and flatpak updates
notify(
"System Updater",
"System passed checks, updating ...",
)
users = []
try:
users = get_active_sessions()
Expand Down
42 changes: 42 additions & 0 deletions tests/unit/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,48 @@ def test_run_updates_system(
["universal-blue-update-reboot=Reboot Now"],
)

@patch("ublue_update.cli.os")
@patch("ublue_update.cli.get_active_sessions")
@patch("ublue_update.cli.acquire_lock")
@patch("ublue_update.cli.transaction_wait")
@patch("ublue_update.cli.subprocess.run")
@patch("ublue_update.cli.log")
@patch("ublue_update.cli.pending_deployment_check")
@patch("ublue_update.cli.cfg")
@patch("ublue_update.cli.release_lock")
@patch("ublue_update.cli.notify")
def test_run_updates_without_image_update(
mock_notify,
mock_release_lock,
mock_cfg,
mock_pending_deployment_check,
mock_log,
mock_run,
mock_transaction_wait,
mock_acquire_lock,
mock_get_active_sesions,
mock_os,
):
mock_os.getuid.return_value = 0
mock_acquire_lock.return_value = 3
output = MagicMock(stdout=b"test log")
output.returncode = 1
mock_run.return_value = output
mock_pending_deployment_check.return_value = True
mock_cfg.dbus_notify.return_value = True
# System Update, but no Image Update Available
run_updates(True, False)
mock_notify.assert_not_called()
mock_run.assert_any_call(
[
"/usr/bin/topgrade",
"--config",
"/usr/share/ublue-update/topgrade-system.toml",
],
capture_output=True,
)
mock_notify.assert_not_called()


@patch("ublue_update.cli.os")
@patch("ublue_update.cli.get_active_sessions")
Expand Down

0 comments on commit dce31e5

Please sign in to comment.