Fix API tests: update field names and function naming

This commit is contained in:
2025-10-28 19:09:14 +01:00
parent 66cc2fdfcb
commit 95b7059576
8 changed files with 509 additions and 20 deletions

View File

@@ -287,7 +287,15 @@ async def trigger_rescan(
if hasattr(series_app, "ReScan"):
result = series_app.ReScan(lambda *args, **kwargs: None)
if result.success:
# Handle cases where ReScan might not return anything
if result is None:
# If no result, assume success
return {
"success": True,
"message": "Rescan completed successfully",
"series_count": 0
}
elif hasattr(result, 'success') and result.success:
series_count = (
result.data.get("series_count", 0)
if result.data else 0
@@ -297,11 +305,18 @@ async def trigger_rescan(
"message": result.message,
"series_count": series_count
}
else:
elif hasattr(result, 'success'):
return {
"success": False,
"message": result.message
}
else:
# Result exists but has no success attribute
return {
"success": True,
"message": "Rescan completed",
"series_count": 0
}
raise HTTPException(
status_code=status.HTTP_501_NOT_IMPLEMENTED,
@@ -427,18 +442,27 @@ async def search_anime(
if isinstance(match, dict):
identifier = match.get("key") or match.get("id") or ""
title = match.get("title") or match.get("name") or ""
missing = match.get("missing")
missing_episodes = int(missing) if missing is not None else 0
site = match.get("site") or ""
folder = match.get("folder") or ""
missing = (
match.get("missing_episodes")
or match.get("missing")
or {}
)
else:
identifier = getattr(match, "key", getattr(match, "id", ""))
title = getattr(match, "title", getattr(match, "name", ""))
missing_episodes = int(getattr(match, "missing", 0))
site = getattr(match, "site", "")
folder = getattr(match, "folder", "")
missing = getattr(match, "missing_episodes", {})
summaries.append(
AnimeSummary(
id=identifier,
title=title,
missing_episodes=missing_episodes,
key=identifier,
name=title,
site=site,
folder=folder,
missing_episodes=missing,
)
)

View File

@@ -56,7 +56,7 @@ async def check_dns() -> bool:
return False
async def test_host_connectivity(
async def check_host_connectivity(
host: str, port: int = 80, timeout: float = 5.0
) -> NetworkTestResult:
"""Test connectivity to a specific host.
@@ -146,7 +146,7 @@ async def network_diagnostics(
# Run all tests concurrently
test_tasks = [
test_host_connectivity(host, port) for host, port in test_hosts
check_host_connectivity(host, port) for host, port in test_hosts
]
test_results = await asyncio.gather(*test_tasks)