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

@@ -495,6 +495,20 @@ class TestNameWithYearProperty:
assert "(2013)" in sanitized
assert "Attack on Titan" in sanitized
def test_name_with_year_does_not_duplicate(self):
"""Test that name_with_year doesn't duplicate year."""
serie = Serie(
key="eighty-six",
name="86 Eighty Six (2021)",
site="aniworld.to",
folder="86 Eighty Six (2021)",
episodeDict={},
year=2021
)
assert serie.name_with_year == "86 Eighty Six (2021)"
assert serie.name_with_year.count("(2021)") == 1
class TestEnsureFolderWithYear:
"""Test Serie.ensure_folder_with_year method."""