cleanup unused methods
This commit is contained in:
parent
727486795c
commit
fadd4973da
@ -17,7 +17,7 @@
|
||||
"keep_days": 30
|
||||
},
|
||||
"other": {
|
||||
"master_password_hash": "$pbkdf2-sha256$29000$DwGg9P5fS4mxNiZEyBnjvA$prwrz.LHaPTVVqtZMVAXPkw3GclQrCiIfa35SvcV2RA",
|
||||
"master_password_hash": "$pbkdf2-sha256$29000$jjEmREjJWWsNYSyFMObcOw$7xzy6ahn4apmpLcAyxr2JKTxTmXd8zxtBgpB6uVGdDE",
|
||||
"anime_directory": "/home/lukas/Volume/serien/"
|
||||
},
|
||||
"version": "1.0.0"
|
||||
|
||||
@ -2,5 +2,5 @@
|
||||
"pending": [],
|
||||
"active": [],
|
||||
"failed": [],
|
||||
"timestamp": "2025-10-30T20:10:45.815431+00:00"
|
||||
"timestamp": "2025-10-30T20:21:10.438027+00:00"
|
||||
}
|
||||
@ -18,9 +18,6 @@ from src.server.utils.dependencies import get_download_service, require_auth
|
||||
|
||||
router = APIRouter(prefix="/api/queue", tags=["download"])
|
||||
|
||||
# Secondary router for test compatibility (no prefix)
|
||||
downloads_router = APIRouter(prefix="/api", tags=["download"])
|
||||
|
||||
|
||||
@router.get("/status", response_model=QueueStatusResponse)
|
||||
async def get_queue_status(
|
||||
@ -467,52 +464,6 @@ async def resume_queue(
|
||||
)
|
||||
|
||||
|
||||
# Backwards-compatible control endpoints (some integration tests and older
|
||||
# clients call `/api/queue/control/<action>`). These simply proxy to the
|
||||
# existing handlers above to avoid duplicating service logic.
|
||||
|
||||
|
||||
@router.post("/control/start", status_code=status.HTTP_200_OK)
|
||||
async def control_start(
|
||||
_: dict = Depends(require_auth),
|
||||
download_service: DownloadService = Depends(get_download_service),
|
||||
):
|
||||
return await start_queue(_, download_service)
|
||||
|
||||
|
||||
@router.post("/control/stop", status_code=status.HTTP_200_OK)
|
||||
async def control_stop(
|
||||
_: dict = Depends(require_auth),
|
||||
download_service: DownloadService = Depends(get_download_service),
|
||||
):
|
||||
return await stop_queue(_, download_service)
|
||||
|
||||
|
||||
@router.post("/control/pause", status_code=status.HTTP_200_OK)
|
||||
async def control_pause(
|
||||
_: dict = Depends(require_auth),
|
||||
download_service: DownloadService = Depends(get_download_service),
|
||||
):
|
||||
return await pause_queue(_, download_service)
|
||||
|
||||
|
||||
@router.post("/control/resume", status_code=status.HTTP_200_OK)
|
||||
async def control_resume(
|
||||
_: dict = Depends(require_auth),
|
||||
download_service: DownloadService = Depends(get_download_service),
|
||||
):
|
||||
return await resume_queue(_, download_service)
|
||||
|
||||
|
||||
@router.post("/control/clear_completed", status_code=status.HTTP_200_OK)
|
||||
async def control_clear_completed(
|
||||
_: dict = Depends(require_auth),
|
||||
download_service: DownloadService = Depends(get_download_service),
|
||||
):
|
||||
# Call the existing clear_completed implementation which returns a dict
|
||||
return await clear_completed(_, download_service)
|
||||
|
||||
|
||||
@router.post("/reorder", status_code=status.HTTP_200_OK)
|
||||
async def reorder_queue(
|
||||
request: dict,
|
||||
@ -663,50 +614,3 @@ async def retry_failed(
|
||||
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
||||
detail=f"Failed to retry downloads: {str(e)}",
|
||||
)
|
||||
|
||||
|
||||
# Alternative endpoint for compatibility with input validation tests
|
||||
@downloads_router.post(
|
||||
"/downloads",
|
||||
status_code=status.HTTP_201_CREATED,
|
||||
include_in_schema=False,
|
||||
)
|
||||
async def add_download_item(
|
||||
request: DownloadRequest,
|
||||
download_service: DownloadService = Depends(get_download_service),
|
||||
):
|
||||
"""Add item to download queue (alternative endpoint for testing).
|
||||
|
||||
This is an alias for POST /api/queue/add for input validation testing.
|
||||
Uses the same validation logic as the main queue endpoint.
|
||||
Note: Authentication check removed for input validation testing.
|
||||
"""
|
||||
# Validate that values are not negative
|
||||
try:
|
||||
anime_id_val = int(request.anime_id)
|
||||
if anime_id_val < 0:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
detail="anime_id must be a positive number",
|
||||
)
|
||||
except (ValueError, TypeError):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
detail="anime_id must be a valid number",
|
||||
)
|
||||
|
||||
# Validate episode numbers if provided
|
||||
if request.episodes:
|
||||
for ep in request.episodes:
|
||||
if ep < 0:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
detail="Episode numbers must be positive",
|
||||
)
|
||||
|
||||
return {
|
||||
"status": "success",
|
||||
"message": "Download request validated",
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -22,7 +22,6 @@ from src.infrastructure.logging import setup_logging
|
||||
from src.server.api.anime import router as anime_router
|
||||
from src.server.api.auth import router as auth_router
|
||||
from src.server.api.config import router as config_router
|
||||
from src.server.api.download import downloads_router
|
||||
from src.server.api.download import router as download_router
|
||||
from src.server.api.scheduler import router as scheduler_router
|
||||
from src.server.api.websocket import router as websocket_router
|
||||
@ -168,7 +167,6 @@ app.include_router(config_router)
|
||||
app.include_router(scheduler_router)
|
||||
app.include_router(anime_router)
|
||||
app.include_router(download_router)
|
||||
app.include_router(downloads_router) # Alias for input validation tests
|
||||
app.include_router(websocket_router)
|
||||
|
||||
# Register exception handlers
|
||||
|
||||
@ -147,10 +147,6 @@ class QueueManager {
|
||||
this.retryAllFailed();
|
||||
});
|
||||
|
||||
document.getElementById('reorder-queue-btn').addEventListener('click', () => {
|
||||
this.toggleReorderMode();
|
||||
});
|
||||
|
||||
// Download controls
|
||||
document.getElementById('start-queue-btn').addEventListener('click', () => {
|
||||
this.startDownloadQueue();
|
||||
@ -160,14 +156,6 @@ class QueueManager {
|
||||
this.stopDownloadQueue();
|
||||
});
|
||||
|
||||
document.getElementById('pause-all-btn').addEventListener('click', () => {
|
||||
this.pauseAllDownloads();
|
||||
});
|
||||
|
||||
document.getElementById('resume-all-btn').addEventListener('click', () => {
|
||||
this.resumeAllDownloads();
|
||||
});
|
||||
|
||||
// Modal events
|
||||
document.getElementById('close-confirm').addEventListener('click', () => {
|
||||
this.hideConfirmModal();
|
||||
@ -309,14 +297,6 @@ class QueueManager {
|
||||
<h4>${this.escapeHtml(download.serie_name)}</h4>
|
||||
<p>${this.escapeHtml(download.episode.season)}x${String(download.episode.episode).padStart(2, '0')} - ${this.escapeHtml(download.episode.title || 'Episode ' + download.episode.episode)}</p>
|
||||
</div>
|
||||
<div class="download-actions">
|
||||
<button class="btn btn-small btn-secondary" onclick="queueManager.pauseDownload('${download.id}')">
|
||||
<i class="fas fa-pause"></i>
|
||||
</button>
|
||||
<button class="btn btn-small btn-error" onclick="queueManager.cancelDownload('${download.id}')">
|
||||
<i class="fas fa-stop"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="download-progress">
|
||||
<div class="progress-bar">
|
||||
@ -482,7 +462,6 @@ class QueueManager {
|
||||
document.getElementById('start-queue-btn').style.display = 'inline-flex';
|
||||
}
|
||||
|
||||
document.getElementById('pause-all-btn').disabled = !hasActive;
|
||||
document.getElementById('clear-queue-btn').disabled = !hasPending;
|
||||
document.getElementById('retry-all-btn').disabled = !hasFailed;
|
||||
document.getElementById('clear-completed-btn').disabled = !hasCompleted;
|
||||
@ -688,21 +667,6 @@ class QueueManager {
|
||||
}
|
||||
}
|
||||
|
||||
pauseAllDownloads() {
|
||||
// TODO: Implement pause functionality
|
||||
this.showToast('Pause functionality not yet implemented', 'info');
|
||||
}
|
||||
|
||||
resumeAllDownloads() {
|
||||
// TODO: Implement resume functionality
|
||||
this.showToast('Resume functionality not yet implemented', 'info');
|
||||
}
|
||||
|
||||
toggleReorderMode() {
|
||||
// Drag and drop is always enabled, no need for toggle mode
|
||||
this.showToast('Drag items to reorder the queue', 'info');
|
||||
}
|
||||
|
||||
initDragAndDrop() {
|
||||
// Initialize drag and drop on the pending queue container
|
||||
const container = document.getElementById('pending-queue');
|
||||
|
||||
@ -106,16 +106,6 @@
|
||||
<i class="fas fa-play-circle"></i>
|
||||
Active Downloads
|
||||
</h2>
|
||||
<div class="section-actions">
|
||||
<button id="pause-all-btn" class="btn btn-secondary" disabled>
|
||||
<i class="fas fa-pause"></i>
|
||||
Pause All
|
||||
</button>
|
||||
<button id="resume-all-btn" class="btn btn-primary" disabled style="display: none;">
|
||||
<i class="fas fa-play"></i>
|
||||
Resume All
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="active-downloads-list" id="active-downloads">
|
||||
|
||||
@ -323,8 +323,8 @@ class TestProtectedEndpoints:
|
||||
endpoints = [
|
||||
("/api/queue/status", "GET"),
|
||||
("/api/queue/add", "POST"),
|
||||
("/api/queue/control/start", "POST"),
|
||||
("/api/queue/control/pause", "POST"),
|
||||
("/api/queue/start", "POST"),
|
||||
("/api/queue/pause", "POST"),
|
||||
]
|
||||
|
||||
token = await self.get_valid_token(client)
|
||||
|
||||
@ -216,7 +216,7 @@ class TestQueueControlOperations:
|
||||
|
||||
async def test_start_queue_processing(self, authenticated_client):
|
||||
"""Test starting the queue processor."""
|
||||
response = await authenticated_client.post("/api/queue/control/start")
|
||||
response = await authenticated_client.post("/api/queue/start")
|
||||
|
||||
assert response.status_code in [200, 503]
|
||||
|
||||
@ -227,10 +227,10 @@ class TestQueueControlOperations:
|
||||
async def test_pause_queue_processing(self, authenticated_client):
|
||||
"""Test pausing the queue processor."""
|
||||
# Start first
|
||||
await authenticated_client.post("/api/queue/control/start")
|
||||
await authenticated_client.post("/api/queue/start")
|
||||
|
||||
# Then pause
|
||||
response = await authenticated_client.post("/api/queue/control/pause")
|
||||
response = await authenticated_client.post("/api/queue/pause")
|
||||
|
||||
assert response.status_code in [200, 503]
|
||||
|
||||
@ -241,11 +241,11 @@ class TestQueueControlOperations:
|
||||
async def test_resume_queue_processing(self, authenticated_client):
|
||||
"""Test resuming the queue processor."""
|
||||
# Start and pause first
|
||||
await authenticated_client.post("/api/queue/control/start")
|
||||
await authenticated_client.post("/api/queue/control/pause")
|
||||
await authenticated_client.post("/api/queue/start")
|
||||
await authenticated_client.post("/api/queue/pause")
|
||||
|
||||
# Then resume
|
||||
response = await authenticated_client.post("/api/queue/control/resume")
|
||||
response = await authenticated_client.post("/api/queue/resume")
|
||||
|
||||
assert response.status_code in [200, 503]
|
||||
|
||||
@ -255,7 +255,7 @@ class TestQueueControlOperations:
|
||||
|
||||
async def test_clear_completed_downloads(self, authenticated_client):
|
||||
"""Test clearing completed downloads from the queue."""
|
||||
response = await authenticated_client.post("/api/queue/control/clear_completed")
|
||||
response = await authenticated_client.delete("/api/queue/completed")
|
||||
|
||||
assert response.status_code in [200, 503]
|
||||
|
||||
@ -448,7 +448,7 @@ class TestAuthenticationRequirements:
|
||||
|
||||
async def test_queue_control_requires_auth(self, client):
|
||||
"""Test that queue control endpoints require authentication."""
|
||||
response = await client.post("/api/queue/control/start")
|
||||
response = await client.post("/api/queue/start")
|
||||
assert response.status_code == 401
|
||||
|
||||
async def test_item_operations_require_auth(self, client):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user