Fix Issue 5: Create NFOServiceFactory for centralized initialization

- Created NFOServiceFactory in src/core/services/nfo_factory.py
- Enforces configuration precedence: explicit params > ENV > config.json
- Provides create() and create_optional() methods
- Singleton factory instance via get_nfo_factory()
- Updated 4 files to use factory (nfo.py, SeriesApp.py, series_manager_service.py, nfo_cli.py)
- Fixed test mocks: added ensure_folder_with_year(), corrected dependency test
- Tests: 17/18 NFO passing, 15/16 anime passing
- Resolves Code Duplication 2 (NFO initialization)
This commit is contained in:
2026-01-24 21:52:54 +01:00
parent 52d82ab6bc
commit fb8f0bdbd2
8 changed files with 356 additions and 76 deletions

View File

@@ -165,7 +165,7 @@ async def get_optional_database_session() -> AsyncGenerator:
"""
try:
from src.server.database import get_db_session
# Try to get a session - if database not initialized, this will raise RuntimeError
async with get_db_session() as session:
try: