af60ca446d
The fabledscryer->steward rename had only ever reached host_agent. The other five bundled plugins (http, snmp, traefik, unifi, docker) still imported `from fabledscryer.*` (package no longer exists) and read FABLEDSCRYER_* env vars — so every one of them was broken at import since the original rebrand. CI stayed green only because none are enabled by default and migrations don't import plugin modules. Now that they version in-tree, complete the rename: - fabledscryer.* -> steward.* imports across all five plugins - FABLEDSCRYER_* -> STEWARD_* in plugin migration env.py files - author/repository/homepage + user-facing 'Fabled Scryer' strings -> Steward - snmp/scheduler.py: also drop dead `now`/datetime; record_metric from steward Adds tests/test_no_legacy_names.py — fails if 'scryer'/'roundtable' ever reappear in shipped code (the drift bit twice; this stops a third time). Also clears pre-existing ruff lint debt (unused imports, semicolon statements, mid-file import) surfaced by the new lint lane. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
39 lines
1.3 KiB
Python
39 lines
1.3 KiB
Python
import textwrap
|
|
import pytest
|
|
from steward.config import load_bootstrap
|
|
|
|
|
|
def test_load_bootstrap_from_yaml(tmp_path):
|
|
cfg_file = tmp_path / "config.yaml"
|
|
cfg_file.write_text(textwrap.dedent("""\
|
|
database:
|
|
url: postgresql+asyncpg://user:pass@localhost/steward
|
|
secret_key: test-secret
|
|
"""))
|
|
cfg = load_bootstrap(cfg_file)
|
|
assert cfg["database_url"] == "postgresql+asyncpg://user:pass@localhost/steward"
|
|
assert cfg["secret_key"] == "test-secret"
|
|
|
|
|
|
def test_env_var_database_url_overrides_yaml(tmp_path, monkeypatch):
|
|
cfg_file = tmp_path / "config.yaml"
|
|
cfg_file.write_text("database:\n url: original\nsecret_key: s\n")
|
|
monkeypatch.setenv("STEWARD_DATABASE_URL", "overridden")
|
|
cfg = load_bootstrap(cfg_file)
|
|
assert cfg["database_url"] == "overridden"
|
|
|
|
|
|
def test_env_var_secret_key_overrides_yaml(tmp_path, monkeypatch):
|
|
cfg_file = tmp_path / "config.yaml"
|
|
cfg_file.write_text("database:\n url: x\nsecret_key: from-yaml\n")
|
|
monkeypatch.setenv("STEWARD_SECRET_KEY", "from-env")
|
|
cfg = load_bootstrap(cfg_file)
|
|
assert cfg["secret_key"] == "from-env"
|
|
|
|
|
|
def test_missing_database_url_raises(tmp_path):
|
|
cfg_file = tmp_path / "config.yaml"
|
|
cfg_file.write_text("secret_key: s\n")
|
|
with pytest.raises(ValueError, match="Database URL is required"):
|
|
load_bootstrap(cfg_file)
|