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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user