chore: remove expired v0.3.1 compatibility shims (#5106)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
"""Regression tests for legacy-stem session handling."""
|
||||
"""Tests for retired legacy session storage paths."""
|
||||
|
||||
import json
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
@@ -6,15 +7,11 @@ from pathlib import Path
|
||||
from nanobot.session.manager import SessionManager
|
||||
|
||||
|
||||
def test_list_sessions_repairs_corrupt_legacy_stem(tmp_path: Path, monkeypatch) -> None:
|
||||
monkeypatch.setattr(
|
||||
"nanobot.session.manager.get_legacy_sessions_dir",
|
||||
lambda: tmp_path / "legacy_sessions",
|
||||
)
|
||||
def test_list_sessions_ignores_legacy_stem(tmp_path: Path) -> None:
|
||||
manager = SessionManager(tmp_path / "workspace")
|
||||
|
||||
# Simulate a legacy lossy-path filename (telegram_12345.jsonl) with a corrupt
|
||||
# first line that triggers the repair branch in list_sessions.
|
||||
# A legacy lossy-path filename must not be treated as current session storage,
|
||||
# even when the file contains otherwise recoverable records.
|
||||
legacy_stem = "telegram_12345"
|
||||
corrupt_path = manager.sessions_dir / f"{legacy_stem}.jsonl"
|
||||
corrupt_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
@@ -24,7 +21,6 @@ def test_list_sessions_repairs_corrupt_legacy_stem(tmp_path: Path, monkeypatch)
|
||||
"created_at": datetime(2025, 1, 1).isoformat(),
|
||||
"updated_at": datetime(2025, 1, 1).isoformat(),
|
||||
})
|
||||
# Corrupt line followed by valid message
|
||||
corrupt_path.write_text(
|
||||
metadata + "\n{INVALID JSON LINE\n"
|
||||
+ json.dumps({"role": "user", "content": "recoverable message"}) + "\n",
|
||||
@@ -33,14 +29,11 @@ def test_list_sessions_repairs_corrupt_legacy_stem(tmp_path: Path, monkeypatch)
|
||||
|
||||
sessions = manager.list_sessions()
|
||||
|
||||
# BUG: repair fails because _repair re-encodes the fallback_key via
|
||||
# _get_session_path, producing a base64 stem that doesn't match the
|
||||
# actual legacy filename. The session is silently dropped.
|
||||
assert len(sessions) == 1, f"Expected 1 session, got {len(sessions)}"
|
||||
assert sessions[0]["key"] == "telegram:12345"
|
||||
assert sessions == []
|
||||
assert corrupt_path.exists()
|
||||
|
||||
|
||||
def test_read_session_methods_fall_back_to_legacy_lossy_stem(
|
||||
def test_read_session_methods_ignore_legacy_lossy_stem(
|
||||
tmp_path: Path,
|
||||
monkeypatch,
|
||||
) -> None:
|
||||
@@ -69,8 +62,5 @@ def test_read_session_methods_fall_back_to_legacy_lossy_stem(
|
||||
metadata_result = manager.read_session_metadata(key)
|
||||
file_result = manager.read_session_file(key)
|
||||
|
||||
assert metadata_result is not None
|
||||
assert metadata_result["metadata"] == metadata["metadata"]
|
||||
assert file_result is not None
|
||||
assert file_result["metadata"] == metadata["metadata"]
|
||||
assert file_result["messages"] == []
|
||||
assert metadata_result is None
|
||||
assert file_result is None
|
||||
|
||||
Reference in New Issue
Block a user