fix(cron): keep homeassistant toolset enabled when HASS_TOKEN is set (#16208)
After #14798 made cron honor per-platform `hermes tools` config, the `_DEFAULT_OFF_TOOLSETS` filter silently stripped `homeassistant` from cron jobs for users who'd been relying on the previous blanket toolset. Norbert's HA cron reports regressed as a result. The HA toolset is already runtime-gated by its `check_fn` (requires HASS_TOKEN to register any tools). When HASS_TOKEN is set the user has explicitly opted in — `_DEFAULT_OFF_TOOLSETS` adds nothing in that case, so stop double-gating and restore HA for cron / cli / other platforms without an explicit saved toolset list. moa and rl stay off by default (original #14798 goal preserved). Fixes HA cron regression reported by Norbert.
This commit is contained in:
@@ -41,6 +41,36 @@ def test_get_platform_tools_homeassistant_platform_keeps_homeassistant_toolset()
|
||||
assert "homeassistant" in enabled
|
||||
|
||||
|
||||
def test_get_platform_tools_homeassistant_toolset_enabled_for_cron_when_hass_token_set(monkeypatch):
|
||||
"""HA toolset is runtime-gated by check_fn (requires HASS_TOKEN).
|
||||
|
||||
When HASS_TOKEN is set, the user has explicitly opted in — _DEFAULT_OFF_TOOLSETS
|
||||
shouldn't also strip HA from platforms (like cron) that run through
|
||||
_get_platform_tools without an explicit saved toolset list.
|
||||
|
||||
Regression guard for Norbert's HA cron breakage after #14798 made cron
|
||||
honor per-platform tool config.
|
||||
"""
|
||||
monkeypatch.setenv("HASS_TOKEN", "fake-test-token")
|
||||
|
||||
cron_enabled = _get_platform_tools({}, "cron")
|
||||
assert "homeassistant" in cron_enabled
|
||||
# moa must stay off — the original goal of #14798
|
||||
assert "moa" not in cron_enabled
|
||||
|
||||
cli_enabled = _get_platform_tools({}, "cli")
|
||||
assert "homeassistant" in cli_enabled
|
||||
|
||||
|
||||
def test_get_platform_tools_homeassistant_toolset_off_for_cron_when_hass_token_missing(monkeypatch):
|
||||
"""Without HASS_TOKEN, HA stays off by default — preserves #14798's behavior
|
||||
for users who never configured HA."""
|
||||
monkeypatch.delenv("HASS_TOKEN", raising=False)
|
||||
|
||||
cron_enabled = _get_platform_tools({}, "cron")
|
||||
assert "homeassistant" not in cron_enabled
|
||||
|
||||
|
||||
def test_get_platform_tools_preserves_explicit_empty_selection():
|
||||
config = {"platform_toolsets": {"cli": []}}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user