diff --git a/uaclient/api/tests/test_api_u_unattended_upgrades_status_v1.py b/uaclient/api/tests/test_api_u_unattended_upgrades_status_v1.py index 38dbddcf45..d1c60bf725 100644 --- a/uaclient/api/tests/test_api_u_unattended_upgrades_status_v1.py +++ b/uaclient/api/tests/test_api_u_unattended_upgrades_status_v1.py @@ -45,23 +45,63 @@ class TestIsUnattendedUpgradesRunning: (False, {}, False, UNATTENDED_UPGRADES_SYSTEMD_JOB_DISABLED), ( True, - {"test": []}, + { + "APT::Periodic::Enable": "1", + "APT::Periodic::Update-Package-Lists": "1", + "APT::Periodic::Unattended-Upgrade": "1", + "Unattended-Upgrade::Allowed-Origins": [], + }, False, UNATTENDED_UPGRADES_CFG_LIST_VALUE_EMPTY.format( - cfg_name="test" + cfg_name="Unattended-Upgrade::Allowed-Origins" ), ), ( True, - {"test": ["foo"], "test2": "0"}, + { + "APT::Periodic::Enable": "0", + "APT::Periodic::Update-Package-Lists": "0", + "APT::Periodic::Unattended-Upgrade": "0", + "Unattended-Upgrade::Allowed-Origins": ["foo"], + }, False, UNATTENDED_UPGRADES_CFG_VALUE_TURNED_OFF.format( - cfg_name="test2" + cfg_name="APT::Periodic::Enable" ), ), ( True, - {"test": ["foo"], "test2": "1"}, + { + "APT::Periodic::Enable": "1", + "APT::Periodic::Update-Package-Lists": "0", + "APT::Periodic::Unattended-Upgrade": "1", + "Unattended-Upgrade::Allowed-Origins": ["foo"], + }, + False, + UNATTENDED_UPGRADES_CFG_VALUE_TURNED_OFF.format( + cfg_name="APT::Periodic::Update-Package-Lists" + ), + ), + ( + True, + { + "APT::Periodic::Enable": "1", + "APT::Periodic::Update-Package-Lists": "1", + "APT::Periodic::Unattended-Upgrade": "1", + "Unattended-Upgrade::Allowed-Origins": ["foo"], + }, + True, + None, + ), + ( + True, + { + "APT::Periodic::Enable": "1", + "APT::Periodic::Update-Package-Lists": "1", + "APT::Periodic::Unattended-Upgrade": "1", + "Unattended-Upgrade::Allowed-Origins": ["foo"], + "Unattended-Upgrade::OnlyOnACPower": "0", + }, True, None, ), diff --git a/uaclient/api/u/unattended_upgrades/status/v1.py b/uaclient/api/u/unattended_upgrades/status/v1.py index 6094d6ae37..17073e5247 100644 --- a/uaclient/api/u/unattended_upgrades/status/v1.py +++ b/uaclient/api/u/unattended_upgrades/status/v1.py @@ -160,7 +160,8 @@ def _is_unattended_upgrades_running( if not systemd_apt_timer_enabled: return (False, messages.UNATTENDED_UPGRADES_SYSTEMD_JOB_DISABLED) - for key, value in unattended_upgrades_cfg.items(): + for key in UNATTENDED_UPGRADES_CONFIG_KEYS: + value = unattended_upgrades_cfg.get(key) if not value: return ( False,