fix: prevent duplicate year suffixes in series name and folder creation

Apply the same duplicate-year prevention logic to additional code paths:

- Serie.name_with_year property: skip adding year suffix if name already ends with it
- add_series API endpoint: avoid duplicating year in folder_name_with_year
- Add integration test for Serie.name_with_year idempotency
- Add API test for add_series endpoint year deduplication

Complements the folder_rename_service fix for comprehensive coverage.
This commit is contained in:
2026-05-19 21:25:21 +02:00
parent 75c22fe296
commit 7930e49701
4 changed files with 42 additions and 2 deletions

View File

@@ -334,6 +334,25 @@ async def test_add_series_sanitizes_folder_name(authenticated_client):
assert "?" not in folder
@pytest.mark.asyncio
async def test_add_series_does_not_duplicate_year(authenticated_client):
"""Test that add_series doesn't duplicate year when name already contains it."""
response = await authenticated_client.post(
"/api/anime/add",
json={
"link": "https://aniworld.to/anime/stream/eighty-six",
"name": "86 Eighty Six (2021)"
}
)
assert response.status_code == 202
data = response.json()
# Folder should contain year only once
folder = data["folder"]
assert folder.count("(2021)") == 1
@pytest.mark.asyncio
async def test_add_series_returns_missing_episodes(authenticated_client):
"""Test that add_series returns loading progress info."""