Files
FabledSteward/tests/core/test_settings_default_plugins.py
bvandeusen b49496b57b
CI / lint (push) Successful in 2s
CI / unit (push) Successful in 7s
CI / integration (push) Failing after 2m16s
CI / publish (push) Has been skipped
feat(plugins): default-enable generic bundled plugins on fresh install
A fresh install enabled zero plugins — settings.py DEFAULTS had no plugin.*
keys, so to_plugins_cfg returned {} and every plugin had to be flipped on
by hand. Seed docker, host_agent, http, snmp as default-on (generic, non-
vendor-specific); traefik and unifi stay opt-in. Stored choices override
the default, so disabling persists.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-15 21:24:21 -04:00

42 lines
1.6 KiB
Python

"""Pure-function tests for the default-enabled plugin set.
A fresh install (no stored plugin.* rows) should come up with the generic,
non-vendor-specific bundled plugins already enabled, while vendor-specific
plugins stay opt-in. An operator's stored choice must override the default.
No DB / Quart fixtures — we exercise to_plugins_cfg over the DEFAULTS dict
and a DEFAULTS-merged-with-stored dict, mirroring get_all_settings' merge.
"""
from steward.core import settings as settings_module
from steward.core.settings import DEFAULTS, to_plugins_cfg
DEFAULT_ON = {"docker", "host_agent", "http", "snmp"}
VENDOR_OPT_IN = {"traefik", "unifi"}
def test_generic_plugins_enabled_by_default():
cfg = to_plugins_cfg(DEFAULTS)
for name in DEFAULT_ON:
assert cfg.get(name, {}).get("enabled") is True, name
def test_vendor_plugins_not_enabled_by_default():
cfg = to_plugins_cfg(DEFAULTS)
for name in VENDOR_OPT_IN:
assert name not in cfg, name
def test_stored_choice_overrides_default():
# get_all_settings / load_settings_sync overlay stored values onto DEFAULTS;
# a stored disable must win over the built-in default-on.
merged = {**DEFAULTS, "plugin.docker": {"enabled": False}}
cfg = to_plugins_cfg(merged)
assert cfg["docker"]["enabled"] is False
# untouched defaults remain enabled
assert cfg["http"]["enabled"] is True
def test_defaults_use_plugin_dot_namespace():
# The keys must live under the plugin.<name> namespace to_plugins_cfg reads.
for name in DEFAULT_ON:
assert f"plugin.{name}" in settings_module.DEFAULTS