Fix API tests: update field names and function naming
This commit is contained in:
@@ -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,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user