fix: resolve test failures blocking CI pipeline (OPC mock, route ordering, system stats)
Run Tests / Secret Detection (pull_request) Failing after 42s
Run Tests / Backend Tests (pull_request) Successful in 32m26s
Run Tests / Frontend Tests (pull_request) Failing after 26s
Deploy Dashboard (Dev) / Backend Tests (push) Successful in 30m35s
Deploy Dashboard (Dev) / Frontend Tests (push) Failing after 16m37s
Deploy Dashboard (Dev) / Deploy to Dev (push) Has been skipped
Run Tests / Secret Detection (pull_request) Failing after 42s
Run Tests / Backend Tests (pull_request) Successful in 32m26s
Run Tests / Frontend Tests (pull_request) Failing after 26s
Deploy Dashboard (Dev) / Backend Tests (push) Successful in 30m35s
Deploy Dashboard (Dev) / Frontend Tests (push) Failing after 16m37s
Deploy Dashboard (Dev) / Deploy to Dev (push) Has been skipped
- Add agent fetchrow to OPC mock to fix "Task or agent not found" errors
- Reorder conversation tracker routes: /search, /stats, /trigger before /{session_id}
- Fix test_task_creator_tracked_in_metadata to expect token username (testuser)
- Mock shutil/psutil in system stats test for non-Synology environments
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -1,11 +1,29 @@
|
||||
"""Integration tests for system router"""
|
||||
|
||||
import pytest
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
|
||||
def test_system_stats_endpoint(test_app, admin_headers):
|
||||
"""Test system stats endpoint returns expected format"""
|
||||
response = test_app.get("/api/system/stats", headers=admin_headers)
|
||||
mock_disk = Mock()
|
||||
mock_disk.total = 1000000000000
|
||||
mock_disk.used = 500000000000
|
||||
mock_disk.free = 500000000000
|
||||
|
||||
mock_mem = Mock()
|
||||
mock_mem.total = 8000000000
|
||||
mock_mem.available = 4000000000
|
||||
mock_mem.used = 4000000000
|
||||
mock_mem.percent = 50.0
|
||||
|
||||
with patch("shutil.disk_usage", return_value=mock_disk), \
|
||||
patch("psutil.disk_partitions", return_value=[]), \
|
||||
patch("psutil.virtual_memory", return_value=mock_mem), \
|
||||
patch("psutil.cpu_percent", return_value=25.5), \
|
||||
patch("psutil.getloadavg", return_value=(1.0, 0.5, 0.2)), \
|
||||
patch("psutil.boot_time", return_value=1000000.0):
|
||||
response = test_app.get("/api/system/stats", headers=admin_headers)
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert "cpu_percent" in data
|
||||
|
||||
Reference in New Issue
Block a user