added remove all item from queue
This commit is contained in:
@@ -335,6 +335,22 @@ async def test_clear_completed(authenticated_client, mock_download_service):
|
||||
mock_download_service.clear_completed.assert_called_once()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_clear_pending(authenticated_client, mock_download_service):
|
||||
"""Test DELETE /api/queue/pending endpoint."""
|
||||
mock_download_service.clear_pending = AsyncMock(return_value=3)
|
||||
|
||||
response = await authenticated_client.delete("/api/queue/pending")
|
||||
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
|
||||
assert data["status"] == "success"
|
||||
assert data["count"] == 3
|
||||
|
||||
mock_download_service.clear_pending.assert_called_once()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_retry_failed(authenticated_client, mock_download_service):
|
||||
"""Test POST /api/queue/retry endpoint."""
|
||||
|
||||
@@ -340,6 +340,37 @@ class TestQueueControl:
|
||||
assert count == 1
|
||||
assert len(download_service._completed_items) == 0
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_clear_pending(self, download_service):
|
||||
"""Test clearing all pending downloads from the queue."""
|
||||
# Add multiple items to the queue
|
||||
await download_service.add_to_queue(
|
||||
serie_id="series-1",
|
||||
serie_folder="test-series-1",
|
||||
serie_name="Test Series 1",
|
||||
episodes=[EpisodeIdentifier(season=1, episode=1)],
|
||||
)
|
||||
await download_service.add_to_queue(
|
||||
serie_id="series-2",
|
||||
serie_folder="test-series-2",
|
||||
serie_name="Test Series 2",
|
||||
episodes=[
|
||||
EpisodeIdentifier(season=1, episode=2),
|
||||
EpisodeIdentifier(season=1, episode=3),
|
||||
],
|
||||
)
|
||||
|
||||
# Verify items were added
|
||||
assert len(download_service._pending_queue) == 3
|
||||
|
||||
# Clear pending queue
|
||||
count = await download_service.clear_pending()
|
||||
|
||||
# Verify all pending items were cleared
|
||||
assert count == 3
|
||||
assert len(download_service._pending_queue) == 0
|
||||
assert len(download_service._pending_items_by_id) == 0
|
||||
|
||||
|
||||
class TestPersistence:
|
||||
"""Test queue persistence functionality."""
|
||||
|
||||
Reference in New Issue
Block a user