fix(setup): resolve series key from search link field

- Fix _resolve_key_via_search to use 'title' instead of 'name'
- Extract key from 'link' field URL (e.g., /anime/stream/naruto -> naruto)
- Skip folders with unresolved keys instead of crashing with 'Series key cannot be empty'
- Update tests to use correct field names (title/link)
This commit is contained in:
2026-06-05 20:24:24 +02:00
parent 7b8de8d988
commit 45d259bab2
2 changed files with 16 additions and 7 deletions

View File

@@ -67,7 +67,7 @@ class TestResolveKeyViaSearch:
"""Search returns 1 result with same name → returns key."""
mock_series_app = AsyncMock()
mock_series_app.search.return_value = [
{'key': 'attack-on-titan', 'name': 'Attack on Titan'}
{'title': 'Attack on Titan', 'link': '/anime/stream/attack-on-titan'}
]
with patch(
@@ -97,8 +97,8 @@ class TestResolveKeyViaSearch:
"""Search returns >1 results → returns empty string."""
mock_series_app = AsyncMock()
mock_series_app.search.return_value = [
{'key': 'attack-on-titan', 'name': 'Attack on Titan'},
{'key': 'attack-on-titan-ova', 'name': 'Attack on Titan OVA'}
{'title': 'Attack on Titan', 'link': '/anime/stream/attack-on-titan'},
{'title': 'Attack on Titan OVA', 'link': '/anime/stream/attack-on-titan-ova'}
]
with patch(
@@ -114,7 +114,7 @@ class TestResolveKeyViaSearch:
"""Search returns 1 result but name differs (case-insensitive) → returns empty string."""
mock_series_app = AsyncMock()
mock_series_app.search.return_value = [
{'key': 'attack-on-titan', 'name': 'Attack on Titan'}
{'title': 'Attack on Titan', 'link': '/anime/stream/attack-on-titan'}
]
with patch(
@@ -243,7 +243,7 @@ class TestSetupServiceRun:
mock_series_app = AsyncMock()
mock_series_app.search.return_value = [
{'key': 'attack-on-titan', 'name': 'Attack on Titan'}
{'title': 'Attack on Titan', 'link': '/anime/stream/attack-on-titan'}
]
mock_db = AsyncMock()