72 lines
2.5 KiB
Python
72 lines
2.5 KiB
Python
import pytest
|
|
from fastapi.testclient import TestClient
|
|
from jira_webhook_llm.dashboard import router
|
|
from unittest.mock import patch, MagicMock
|
|
import json
|
|
|
|
client = TestClient(router)
|
|
|
|
def test_dashboard_langfuse_disabled():
|
|
with patch('config.settings.langfuse.enabled', False):
|
|
response = client.get("/dashboard")
|
|
assert response.status_code == 200
|
|
assert "Langfuse monitoring is disabled" in response.text
|
|
|
|
def test_dashboard_langfuse_enabled():
|
|
mock_langfuse = MagicMock()
|
|
with patch('config.settings.langfuse.enabled', True), \
|
|
patch('config.settings.langfuse_client', mock_langfuse):
|
|
response = client.get("/dashboard")
|
|
assert response.status_code == 200
|
|
assert "System Monitoring Dashboard" in response.text
|
|
assert "Plotly.newPlot" in response.text
|
|
|
|
def test_queue_depth_data():
|
|
from jira_webhook_llm.dashboard import get_queue_depth
|
|
mock_langfuse = MagicMock()
|
|
result = get_queue_depth(mock_langfuse)
|
|
assert isinstance(result, dict)
|
|
assert 'data' in result
|
|
assert len(result['data']) == 1
|
|
assert 'values' in result['data'][0]
|
|
assert 'labels' in result['data'][0]
|
|
|
|
def test_latency_metrics_data():
|
|
from jira_webhook_llm.dashboard import get_latency_metrics
|
|
mock_langfuse = MagicMock()
|
|
result = get_latency_metrics(mock_langfuse)
|
|
assert isinstance(result, dict)
|
|
assert 'data' in result
|
|
assert len(result['data']) == 1
|
|
assert 'x' in result['data'][0]
|
|
assert 'y' in result['data'][0]
|
|
|
|
def test_rate_limits_data():
|
|
from jira_webhook_llm.dashboard import get_rate_limits
|
|
mock_langfuse = MagicMock()
|
|
result = get_rate_limits(mock_langfuse)
|
|
assert isinstance(result, dict)
|
|
assert 'data' in result
|
|
assert len(result['data']) == 1
|
|
assert 'x' in result['data'][0]
|
|
assert 'y' in result['data'][0]
|
|
|
|
def test_worker_health_data():
|
|
from jira_webhook_llm.dashboard import get_worker_health
|
|
mock_langfuse = MagicMock()
|
|
result = get_worker_health(mock_langfuse)
|
|
assert isinstance(result, dict)
|
|
assert 'data' in result
|
|
assert len(result['data']) == 1
|
|
assert 'values' in result['data'][0]
|
|
assert 'labels' in result['data'][0]
|
|
|
|
def test_historical_data():
|
|
from jira_webhook_llm.dashboard import get_historical_data
|
|
mock_langfuse = MagicMock()
|
|
result = get_historical_data(mock_langfuse)
|
|
assert isinstance(result, dict)
|
|
assert 'data' in result
|
|
assert len(result['data']) == 1
|
|
assert 'x' in result['data'][0]
|
|
assert 'y' in result['data'][0] |