fixed some tests
This commit is contained in:
@@ -101,9 +101,19 @@ def test_get_anime_detail_direct_call():
|
||||
|
||||
def test_rescan_direct_call():
|
||||
"""Test trigger_rescan function directly."""
|
||||
fake = FakeSeriesApp()
|
||||
result = asyncio.run(anime_module.trigger_rescan(series_app=fake))
|
||||
from unittest.mock import AsyncMock
|
||||
|
||||
from src.server.services.anime_service import AnimeService
|
||||
|
||||
# Create a mock anime service
|
||||
mock_anime_service = AsyncMock(spec=AnimeService)
|
||||
mock_anime_service.rescan = AsyncMock()
|
||||
|
||||
result = asyncio.run(
|
||||
anime_module.trigger_rescan(anime_service=mock_anime_service)
|
||||
)
|
||||
assert result["success"] is True
|
||||
mock_anime_service.rescan.assert_called_once()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
||||
@@ -111,16 +111,19 @@ async def test_get_queue_status(authenticated_client, mock_download_service):
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
|
||||
# Updated to match new response structure
|
||||
assert "is_running" in data
|
||||
assert "is_paused" in data
|
||||
assert "active_downloads" in data
|
||||
assert "pending_queue" in data
|
||||
assert "completed_downloads" in data
|
||||
assert "failed_downloads" in data
|
||||
# Updated to match new response structure with nested status
|
||||
assert "status" in data
|
||||
assert "statistics" in data
|
||||
assert data["is_running"] is True
|
||||
assert data["is_paused"] is False
|
||||
|
||||
status_data = data["status"]
|
||||
assert "is_running" in status_data
|
||||
assert "is_paused" in status_data
|
||||
assert "active_downloads" in status_data
|
||||
assert "pending_queue" in status_data
|
||||
assert "completed_downloads" in status_data
|
||||
assert "failed_downloads" in status_data
|
||||
assert status_data["is_running"] is True
|
||||
assert status_data["is_paused"] is False
|
||||
|
||||
mock_download_service.get_queue_status.assert_called_once()
|
||||
mock_download_service.get_queue_stats.assert_called_once()
|
||||
|
||||
@@ -73,15 +73,16 @@ class TestQueueDisplay:
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
|
||||
# Verify structure
|
||||
assert "is_running" in data
|
||||
# Verify top-level structure
|
||||
assert "status" in data
|
||||
assert "statistics" in data
|
||||
|
||||
# Verify status nested structure
|
||||
status = data["status"]
|
||||
assert "active" in status
|
||||
assert "pending" in status
|
||||
assert "completed" in status
|
||||
assert "failed" in status
|
||||
assert "active_downloads" in status
|
||||
assert "pending_queue" in status
|
||||
assert "completed_downloads" in status
|
||||
assert "failed_downloads" in status
|
||||
assert "is_running" in status
|
||||
assert "is_paused" in status
|
||||
|
||||
@@ -107,7 +108,8 @@ class TestQueueDisplay:
|
||||
assert response.status_code == 200
|
||||
|
||||
data = response.json()
|
||||
pending = data["pending_queue"]
|
||||
# Updated for nested status structure
|
||||
pending = data["status"]["pending_queue"]
|
||||
|
||||
assert len(pending) > 0
|
||||
item = pending[0]
|
||||
@@ -140,7 +142,7 @@ class TestQueueReordering:
|
||||
)
|
||||
existing_items = [
|
||||
item["id"]
|
||||
for item in status_response.json()["pending_queue"]
|
||||
for item in status_response.json()["status"]["pending_queue"]
|
||||
]
|
||||
if existing_items:
|
||||
await client.request(
|
||||
@@ -190,7 +192,7 @@ class TestQueueReordering:
|
||||
)
|
||||
current_order = [
|
||||
item["id"]
|
||||
for item in status_response.json()["pending_queue"]
|
||||
for item in status_response.json()["status"]["pending_queue"]
|
||||
]
|
||||
|
||||
assert current_order == new_order
|
||||
@@ -270,7 +272,7 @@ class TestQueueControl:
|
||||
"/api/queue/status",
|
||||
headers=auth_headers
|
||||
)
|
||||
assert status.json()["is_running"] is False
|
||||
assert status.json()["status"]["is_running"] is False
|
||||
|
||||
# Start queue
|
||||
await client.post("/api/queue/start", headers=auth_headers)
|
||||
@@ -280,7 +282,7 @@ class TestQueueControl:
|
||||
"/api/queue/status",
|
||||
headers=auth_headers
|
||||
)
|
||||
assert status.json()["is_running"] is True
|
||||
assert status.json()["status"]["is_running"] is True
|
||||
|
||||
# Stop queue
|
||||
await client.post("/api/queue/stop", headers=auth_headers)
|
||||
@@ -290,7 +292,7 @@ class TestQueueControl:
|
||||
"/api/queue/status",
|
||||
headers=auth_headers
|
||||
)
|
||||
assert status.json()["is_running"] is False
|
||||
assert status.json()["status"]["is_running"] is False
|
||||
|
||||
|
||||
class TestCompletedDownloads:
|
||||
@@ -323,7 +325,7 @@ class TestCompletedDownloads:
|
||||
data = status.json()
|
||||
|
||||
completed_count = data["statistics"]["completed_count"]
|
||||
completed_list = len(data["completed_downloads"])
|
||||
completed_list = len(data["status"]["completed_downloads"])
|
||||
|
||||
# Count should match list length
|
||||
assert completed_count == completed_list
|
||||
@@ -390,7 +392,7 @@ class TestFailedDownloads:
|
||||
data = status.json()
|
||||
|
||||
failed_count = data["statistics"]["failed_count"]
|
||||
failed_list = len(data["failed_downloads"])
|
||||
failed_list = len(data["status"]["failed_downloads"])
|
||||
|
||||
# Count should match list length
|
||||
assert failed_count == failed_list
|
||||
@@ -443,7 +445,7 @@ class TestBulkOperations:
|
||||
"/api/queue/status",
|
||||
headers=auth_headers
|
||||
)
|
||||
pending = status.json()["status"]["pending"]
|
||||
pending = status.json()["status"]["pending_queue"]
|
||||
|
||||
if pending:
|
||||
item_ids = [item["id"] for item in pending]
|
||||
@@ -463,4 +465,4 @@ class TestBulkOperations:
|
||||
"/api/queue/status",
|
||||
headers=auth_headers
|
||||
)
|
||||
assert len(status.json()["status"]["pending"]) == 0
|
||||
assert len(status.json()["status"]["pending_queue"]) == 0
|
||||
|
||||
Reference in New Issue
Block a user