CodexDashBoard / tests /test_data_error_visibility.py
smlflg's picture
Initial public upload from Projekte/CodexDashBoard
981aa5d verified
Raw History Blame Contribute Delete
1.26 kB
from pathlib import Path
import ast
PROJECT_ROOT = Path(__file__).resolve().parents[1]
APP_PY = PROJECT_ROOT / "src" / "codex_dashboard" / "app.py"
def _method_source(class_name: str, method_name: str) -> str:
source = APP_PY.read_text(encoding="utf-8")
tree = ast.parse(source)
for node in ast.walk(tree):
if isinstance(node, ast.ClassDef) and node.name == class_name:
for item in node.body:
if isinstance(item, ast.FunctionDef) and item.name == method_name:
return ast.get_source_segment(source, item) or ""
raise AssertionError(f"missing {class_name}.{method_name}")
def test_session_refresh_status_distinguishes_database_error_from_no_sessions():
source = _method_source("CodexDashboard", "refresh_sessions")
assert "list_threads_result" in source
assert ".error" in source
assert "Session database error" in source
assert "No Codex sessions found" not in source
def test_log_refresh_status_distinguishes_database_error_from_no_logs():
source = _method_source("CodexDashboard", "refresh_logs")
assert "list_logs_result" in source
assert ".error" in source
assert "Log database error" in source
assert "No Codex logs found" not in source