Files
fgAI/tests/test_dashboard.py
2026-07-06 09:22:13 +02:00

63 lines
2.2 KiB
Python

import json
import unittest
from unittest.mock import patch
from fgai.dashboard import HTML, _ollama_models
class DashboardTests(unittest.TestCase):
def test_ollama_models_returns_sorted_model_names(self):
class Response:
def __enter__(self):
return self
def __exit__(self, *_args):
return False
def read(self):
return json.dumps({"models": [{"name": "qwen3:8b", "size": 2}, {"name": "llama3.1", "size": 1}]}).encode("utf-8")
with patch("fgai.dashboard.request.urlopen", return_value=Response()):
result = _ollama_models()
self.assertEqual(result["status"], "ok")
self.assertEqual([item["name"] for item in result["models"]], ["llama3.1", "qwen3:8b"])
def test_dashboard_includes_how_to_view(self):
self.assertIn('data-tab="howto"', HTML)
self.assertIn('data-view="howto"', HTML)
self.assertIn("How To Use SignalScope", HTML)
def test_dashboard_can_update_existing_recommended_profiles(self):
self.assertIn("Update profile", HTML)
self.assertIn("function mergeProfile", HTML)
def test_dashboard_has_direct_stream_selection_save(self):
self.assertIn("Save streams", HTML)
self.assertIn("function saveStreamSelection", HTML)
def test_dashboard_includes_operator_guidance(self):
self.assertIn("Operator Guidance", HTML)
self.assertIn("function buildActionPlan", HTML)
def test_dashboard_links_evidence_to_graylog(self):
self.assertIn("function graylogEvidenceLink", HTML)
self.assertIn("/search?rangetype=relative", HTML)
def test_dashboard_has_correlation_explorer(self):
self.assertIn("correlationExplorer", HTML)
self.assertIn("function renderCorrelationExplorer", HTML)
self.assertIn("correlationHitboxes", HTML)
def test_dashboard_shows_refreshing_mcp_as_polling_badge(self):
self.assertIn("function mcpCapability", HTML)
self.assertIn("connected, ${suffix}", HTML)
def test_dashboard_has_visible_incident_action_status(self):
self.assertIn("incidentNotice", HTML)
self.assertIn("Incident marked", HTML)
if __name__ == "__main__":
unittest.main()