download re implemented

This commit is contained in:
2025-10-30 22:06:41 +01:00
parent 6ebc2ed2ea
commit 3be175522f
16 changed files with 359 additions and 1335 deletions

View File

@@ -224,35 +224,6 @@ class TestQueueControlOperations:
data = response.json()
assert data["status"] == "success"
async def test_pause_queue_processing(self, authenticated_client):
"""Test pausing the queue processor."""
# Start first
await authenticated_client.post("/api/queue/start")
# Then pause
response = await authenticated_client.post("/api/queue/pause")
assert response.status_code in [200, 503]
if response.status_code == 200:
data = response.json()
assert data["status"] == "success"
async def test_resume_queue_processing(self, authenticated_client):
"""Test resuming the queue processor."""
# Start and pause first
await authenticated_client.post("/api/queue/start")
await authenticated_client.post("/api/queue/pause")
# Then resume
response = await authenticated_client.post("/api/queue/resume")
assert response.status_code in [200, 503]
if response.status_code == 200:
data = response.json()
assert data["status"] == "success"
async def test_clear_completed_downloads(self, authenticated_client):
"""Test clearing completed downloads from the queue."""
response = await authenticated_client.delete("/api/queue/completed")
@@ -294,36 +265,9 @@ class TestQueueItemOperations:
# For now, test the endpoint with a dummy ID
response = await authenticated_client.post("/api/queue/items/dummy-id/retry")
# Should return 404 if item doesn't exist, or 503 if service unavailable
# Should return 404 if item doesn't exist, or 503 if unavailable
assert response.status_code in [200, 404, 503]
async def test_reorder_queue_items(self, authenticated_client):
"""Test reordering queue items."""
# Add multiple items
item_ids = []
for i in range(3):
add_response = await authenticated_client.post(
"/api/queue/add",
json={
"serie_id": f"series-{i}",
"serie_name": f"Series {i}",
"episodes": [{"season": 1, "episode": 1}],
"priority": "normal"
}
)
if add_response.status_code == 201:
item_ids.extend(add_response.json()["item_ids"])
if len(item_ids) >= 2:
# Reorder items
response = await authenticated_client.post(
"/api/queue/reorder",
json={"item_order": list(reversed(item_ids))}
)
assert response.status_code in [200, 503]
class TestDownloadProgressTracking:
"""Test progress tracking during downloads."""
@@ -598,33 +542,7 @@ class TestCompleteDownloadWorkflow:
assert progress_response.status_code in [200, 503]
# 5. Verify final state (completed or still processing)
final_response = await authenticated_client.get("/api/queue/status")
final_response = await authenticated_client.get(
"/api/queue/status"
)
assert final_response.status_code in [200, 503]
async def test_workflow_with_pause_and_resume(self, authenticated_client):
"""Test download workflow with pause and resume."""
# Add items
await authenticated_client.post(
"/api/queue/add",
json={
"serie_id": "pause-test",
"serie_name": "Pause Test Series",
"episodes": [{"season": 1, "episode": 1}],
"priority": "normal"
}
)
# Start processing
await authenticated_client.post("/api/queue/control/start")
# Pause
pause_response = await authenticated_client.post("/api/queue/control/pause")
assert pause_response.status_code in [200, 503]
# Resume
resume_response = await authenticated_client.post("/api/queue/control/resume")
assert resume_response.status_code in [200, 503]
# Verify queue status
status_response = await authenticated_client.get("/api/queue/status")
assert status_response.status_code in [200, 503]

View File

@@ -60,7 +60,6 @@ async def download_service(anime_service, progress_service):
"""Create a DownloadService with dependencies."""
service = DownloadService(
anime_service=anime_service,
max_concurrent_downloads=2,
progress_service=progress_service,
persistence_path="/tmp/test_queue.json",
)
@@ -173,40 +172,6 @@ class TestWebSocketDownloadIntegration:
assert stop_broadcast is not None
assert stop_broadcast["data"]["is_running"] is False
@pytest.mark.asyncio
async def test_queue_pause_resume_broadcast(
self, download_service
):
"""Test that pause/resume operations broadcast updates."""
broadcasts: List[Dict[str, Any]] = []
async def mock_broadcast(update_type: str, data: dict):
broadcasts.append({"type": update_type, "data": data})
download_service.set_broadcast_callback(mock_broadcast)
# Pause queue
await download_service.pause_queue()
# Resume queue
await download_service.resume_queue()
# Find pause/resume broadcasts
pause_broadcast = next(
(b for b in broadcasts if b["type"] == "queue_paused"),
None,
)
resume_broadcast = next(
(b for b in broadcasts if b["type"] == "queue_resumed"),
None,
)
assert pause_broadcast is not None
assert pause_broadcast["data"]["is_paused"] is True
assert resume_broadcast is not None
assert resume_broadcast["data"]["is_paused"] is False
@pytest.mark.asyncio
async def test_clear_completed_broadcast(
self, download_service