forked from Rockachopa/Timmy-time-dashboard
Merge PR #1491
Consolidate multimodal dashboard fixes and verifier syntax repair
This commit is contained in:
56
tests/scripts/test_multimodal_scripts.py
Normal file
56
tests/scripts/test_multimodal_scripts.py
Normal file
@@ -0,0 +1,56 @@
|
||||
"""Unit tests for multimodal helper scripts."""
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
import scripts.doc_drift_detector as drift
|
||||
import scripts.visual_log_analyzer as logs
|
||||
|
||||
pytestmark = pytest.mark.unit
|
||||
|
||||
|
||||
def test_scan_codebase_finds_python_and_config(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
src = tmp_path / "src"
|
||||
src.mkdir()
|
||||
(src / "alpha.py").write_text(
|
||||
"import json\n\n\ndef do_work():\n return json.dumps({'ok': True})\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
(tmp_path / "settings.yml").write_text("enabled: true\n", encoding="utf-8")
|
||||
|
||||
monkeypatch.chdir(tmp_path)
|
||||
detector = drift.ArchitectureDriftDetector(str(src))
|
||||
components = detector.scan_codebase()
|
||||
|
||||
alpha = next(c for c in components if c.name == "alpha")
|
||||
assert alpha.path == "src/alpha.py"
|
||||
assert alpha.component_type == "module"
|
||||
assert alpha.lines_of_code >= 2
|
||||
assert any(c.path.endswith("settings.yml") and c.component_type == "config" for c in components)
|
||||
|
||||
|
||||
def test_detect_drift_matches_normalized_component_names() -> None:
|
||||
detector = drift.ArchitectureDriftDetector("src")
|
||||
diagram = [drift.DiagramComponent(name="Alpha Service", component_type="service")]
|
||||
code = [drift.CodeComponent(name="alpha_service", path="src/alpha_service.py", component_type="module", lines_of_code=75)]
|
||||
|
||||
report = detector.detect_drift(diagram, code)
|
||||
|
||||
assert report.missing_from_code == []
|
||||
assert report.missing_from_docs == []
|
||||
assert report.confidence == 1.0
|
||||
|
||||
|
||||
def test_visual_log_analyzer_builds_prompts() -> None:
|
||||
analyzer = logs.VisualLogAnalyzer()
|
||||
|
||||
analyze = analyzer.analyze_screenshot("/tmp/htop.png", "htop")
|
||||
assert analyze["screenshot_path"] == "/tmp/htop.png"
|
||||
assert analyze["monitor_type"] == "htop"
|
||||
assert "CPU usage above 80%" in analyze["prompt"]
|
||||
assert analyze["instruction"] == "Use vision_analyze tool with this prompt"
|
||||
|
||||
compare = analyzer.compare_screenshots("before.png", "after.png")
|
||||
assert compare["before"] == "before.png"
|
||||
assert compare["after"] == "after.png"
|
||||
assert "Overall health trend" in compare["prompt"] or "Overall health trend".lower() in compare["prompt"].lower()
|
||||
Reference in New Issue
Block a user