mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-08-17 09:36:33 +03:00
fix(session): preserve history across storage relocation
Co-authored-by: lmzopq <1646888+lmzopq@users.noreply.github.com>
This commit is contained in:
+18
-5
@@ -25,14 +25,27 @@ def _isolate_nanobot_log_activation() -> Iterator[None]:
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _isolate_sessions_root(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Iterator[None]:
|
||||
"""Redirect session storage away from the real ~/.nanobot/sessions.
|
||||
"""Redirect session storage away from the real active config data directory.
|
||||
|
||||
Session storage lives under get_legacy_sessions_dir() (outside the workspace,
|
||||
Session storage lives under the active runtime data root (outside the workspace,
|
||||
per ADR-0001), so without redirection tests would write into the real home.
|
||||
"""
|
||||
root = tmp_path / "sessions-root"
|
||||
monkeypatch.setattr("nanobot.session.manager.get_legacy_sessions_dir", lambda: root)
|
||||
monkeypatch.setattr("nanobot.config.paths.get_legacy_sessions_dir", lambda: root)
|
||||
runtime_root = tmp_path.parent / f"{tmp_path.name}-runtime-root"
|
||||
legacy_root = tmp_path.parent / f"{tmp_path.name}-legacy-sessions-root"
|
||||
|
||||
def runtime_subdir(name: str) -> Path:
|
||||
path = runtime_root / name
|
||||
path.mkdir(parents=True, exist_ok=True)
|
||||
return path
|
||||
|
||||
monkeypatch.setattr(
|
||||
"nanobot.session.manager.get_runtime_subdir",
|
||||
runtime_subdir,
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
"nanobot.session.manager.get_legacy_sessions_dir",
|
||||
lambda: legacy_root,
|
||||
)
|
||||
yield
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user