88ab5b917e
Renames the Python package directory, CLI command, env var prefix, docker-compose service/container/image, Postgres role/db, and all visible branding. Marketing form is "Fabled Steward". Clean break from the previous rebrand: drops the fabledscryer→roundtable import shim in __init__.py and the FABLEDSCRYER_* env var fallback in config.py and migrations/env.py. Env vars are now STEWARD_* only. Heads-up for existing deployments: - Postgres user/db renamed fabledscryer → steward in docker-compose.yml. Existing volumes need the role/db renamed inside Postgres, or override POSTGRES_USER/POSTGRES_DB to keep the old names. - Host-agent systemd unit is now steward-agent.service. Existing agents keep running under the old name; reinstall to switch. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
61 lines
1.7 KiB
Python
61 lines
1.7 KiB
Python
# tests/plugins/host_agent/test_agent_config.py
|
|
"""Unit tests for the agent's homegrown config parser."""
|
|
import pytest
|
|
from plugins.host_agent.agent import read_config, ConfigError
|
|
|
|
|
|
def test_parses_flat_key_value(tmp_path):
|
|
p = tmp_path / "agent.conf"
|
|
p.write_text(
|
|
"url = https://steward.example\n"
|
|
"token = abc123\n"
|
|
"interval_seconds = 45\n"
|
|
)
|
|
cfg = read_config(str(p))
|
|
assert cfg["url"] == "https://steward.example"
|
|
assert cfg["token"] == "abc123"
|
|
assert cfg["interval_seconds"] == 45
|
|
|
|
|
|
def test_ignores_blank_lines_and_comments(tmp_path):
|
|
p = tmp_path / "agent.conf"
|
|
p.write_text(
|
|
"# top comment\n"
|
|
"\n"
|
|
"url = https://x\n"
|
|
" # indented comment\n"
|
|
"token = t\n"
|
|
)
|
|
cfg = read_config(str(p))
|
|
# interval_seconds defaults to 30 when unset
|
|
assert cfg["url"] == "https://x"
|
|
assert cfg["token"] == "t"
|
|
|
|
|
|
def test_parses_mounts_as_list(tmp_path):
|
|
p = tmp_path / "agent.conf"
|
|
p.write_text("url = x\ntoken = y\nmounts = /, /mnt/data, /srv\n")
|
|
cfg = read_config(str(p))
|
|
assert cfg["mounts"] == ["/", "/mnt/data", "/srv"]
|
|
|
|
|
|
def test_missing_required_fields_raises(tmp_path):
|
|
p = tmp_path / "agent.conf"
|
|
p.write_text("url = https://x\n")
|
|
with pytest.raises(ConfigError, match="token"):
|
|
read_config(str(p))
|
|
|
|
|
|
def test_malformed_line_raises(tmp_path):
|
|
p = tmp_path / "agent.conf"
|
|
p.write_text("url https://x\ntoken = y\n")
|
|
with pytest.raises(ConfigError):
|
|
read_config(str(p))
|
|
|
|
|
|
def test_default_interval_seconds(tmp_path):
|
|
p = tmp_path / "agent.conf"
|
|
p.write_text("url = x\ntoken = y\n")
|
|
cfg = read_config(str(p))
|
|
assert cfg["interval_seconds"] == 30
|