test(backup): run 9076's three failures (#5673, #5674)
CI / lint (push) Successful in 2s
CI / integration (push) Successful in 1m13s
CI / unit (push) Successful in 1m28s
CI / publish (push) Successful in 1m12s

- The audit-wording guard now reads both branches of a conditional action
  ("backup.made" if ok else "backup.failed"), and its self-test covers that.
- The Backups save test no longer asserts the session's tz, which sign-in
  state sets, not the test.
- The restore integration test uses the app's own metadata. all_metadata
  without plugin dirs imports the `plugins` package as the tests do; loading
  by path under the loader's names is only for `steward restore`. Loading by
  path in the shared test process had mapped traefik and unifi tables a
  second time for later tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-12 07:27:24 -04:00
co-authored by Claude Opus 5.5
parent 49799bd0b3
commit 4c546a9c4d
4 changed files with 18 additions and 9 deletions
+8 -4
View File
@@ -41,7 +41,8 @@ def all_metadata(plugin_dirs: list[Path] | None = None) -> MetaData:
restore runs before anything else would load them. Plugins are found in
`plugin_dirs` (the bootstrap's, bundled first) and loaded by path under
the same module names the app gives them, so a plugin the app already
loaded isn't mapped twice. Without dirs: the repository's plugins/."""
loaded isn't mapped twice. Without dirs (tests, a checkout): the
`plugins` package, as the tests import it."""
import importlib
import sys
@@ -51,15 +52,18 @@ def all_metadata(plugin_dirs: list[Path] | None = None) -> MetaData:
from steward.models.base import Base
roots = [Path(d).resolve() for d in (plugin_dirs or [Path(steward.__file__).parent.parent / "plugins"])]
by_path = bool(plugin_dirs)
names = sorted({p.name for root in roots if root.is_dir() for p in root.iterdir()
if (p / "__init__.py").exists() and (p / "models.py").exists()})
for name in names:
if f"plugins.{name}.models" in sys.modules or f"_steward_plugin_{name}.models" in sys.modules:
continue # already mapped, under one name or the other
path = resolve_plugin_path(roots, name)
try:
package = _import_plugin(name, path)
importlib.import_module(f"{package.__name__}.models")
if by_path:
package = _import_plugin(name, resolve_plugin_path(roots, name)).__name__
else:
package = f"plugins.{name}"
importlib.import_module(f"{package}.models")
except Exception: # a plugin that won't load: its tables are left as pg_restore put them
logger.warning("Restore: couldn't load plugin %r's tables", name, exc_info=True)
return Base.metadata