Rename sync_series_from_data_files to sync_legacy_series_to_db

- Rename function to reflect its legacy status
- Add deprecation warning log on execution
- Update all callers (initialization_service, api/config, fastapi_app)
- Update tests to use new name
- Add deprecation notice to DEVELOPMENT.md

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
2026-05-26 18:45:22 +02:00
parent 53d6da5dac
commit ceb6a2aeb4
8 changed files with 39 additions and 37 deletions

View File

@@ -111,17 +111,17 @@ class TestGetAllSeriesFromDataFiles:
class TestSyncSeriesToDatabase:
"""Test sync_series_from_data_files function from anime_service."""
"""Test sync_legacy_series_to_db function from anime_service."""
@pytest.mark.asyncio
async def test_sync_with_empty_directory(self):
"""Test sync with empty anime directory."""
from src.server.services.anime_service import sync_series_from_data_files
from src.server.services.anime_service import sync_legacy_series_to_db
with tempfile.TemporaryDirectory() as tmp_dir:
with patch('src.core.SeriesApp.Loaders'), \
patch('src.core.SeriesApp.SerieScanner'):
count = await sync_series_from_data_files(tmp_dir)
count = await sync_legacy_series_to_db(tmp_dir)
assert count == 0
# Function should complete successfully with no series
@@ -134,7 +134,7 @@ class TestSyncSeriesToDatabase:
from files and the sync function attempts to add them to the DB.
The actual DB interaction is tested in test_add_to_db_creates_record.
"""
from src.server.services.anime_service import sync_series_from_data_files
from src.server.services.anime_service import sync_legacy_series_to_db
with tempfile.TemporaryDirectory() as tmp_dir:
# Create test data files
@@ -160,7 +160,7 @@ class TestSyncSeriesToDatabase:
patch('src.core.SeriesApp.SerieScanner'):
# The function should return 0 because DB isn't available
# but should not crash
count = await sync_series_from_data_files(tmp_dir)
count = await sync_legacy_series_to_db(tmp_dir)
# Since no real DB, it will fail gracefully
# Function returns 0 when DB operations fail
@@ -170,7 +170,7 @@ class TestSyncSeriesToDatabase:
@pytest.mark.asyncio
async def test_sync_handles_exceptions_gracefully(self):
"""Test that sync handles exceptions without crashing."""
from src.server.services.anime_service import sync_series_from_data_files
from src.server.services.anime_service import sync_legacy_series_to_db
# Make SeriesApp raise an exception during initialization
with patch('src.core.SeriesApp.Loaders'), \
@@ -179,7 +179,7 @@ class TestSyncSeriesToDatabase:
'src.core.SeriesApp.SerieList',
side_effect=Exception("Test error")
):
count = await sync_series_from_data_files("/fake/path")
count = await sync_legacy_series_to_db("/fake/path")
assert count == 0
# Function should complete without crashing

View File

@@ -21,7 +21,7 @@ class TestInitializationWorkflow:
async def test_perform_initial_setup_with_mocked_dependencies(self):
"""Test initial setup completes with minimal mocking."""
# Mock only the external dependencies
with patch('src.server.services.anime_service.sync_series_from_data_files') as mock_sync:
with patch('src.server.services.anime_service.sync_legacy_series_to_db') as mock_sync:
mock_sync.return_value = 0 # No series to sync
# Call the actual function
@@ -241,9 +241,9 @@ class TestModuleStructure:
assert hasattr(initialization_service, 'settings')
def test_sync_series_function_imported(self):
"""Test sync_series_from_data_files is imported."""
assert hasattr(initialization_service, 'sync_series_from_data_files')
assert callable(initialization_service.sync_series_from_data_files)
"""Test sync_legacy_series_to_db is imported."""
assert hasattr(initialization_service, 'sync_legacy_series_to_db')
assert callable(initialization_service.sync_legacy_series_to_db)
# Simpler integration tests that don't require complex mocking
@@ -413,7 +413,7 @@ class TestInitialSetupWorkflow:
async def test_initial_setup_already_completed(self):
"""Test initial setup when already completed."""
with patch.object(initialization_service, '_check_initial_scan_status', return_value=True), \
patch('src.server.services.anime_service.sync_series_from_data_files'):
patch('src.server.services.anime_service.sync_legacy_series_to_db'):
result = await initialization_service.perform_initial_setup()
@@ -425,7 +425,7 @@ class TestInitialSetupWorkflow:
"""Test initial setup with no directory configured."""
with patch.object(initialization_service, '_check_initial_scan_status', return_value=False), \
patch.object(initialization_service, '_validate_anime_directory', return_value=False), \
patch('src.server.services.anime_service.sync_series_from_data_files'):
patch('src.server.services.anime_service.sync_legacy_series_to_db'):
result = await initialization_service.perform_initial_setup()
@@ -440,7 +440,7 @@ class TestInitialSetupWorkflow:
patch.object(initialization_service, '_sync_anime_folders', return_value=5), \
patch.object(initialization_service, '_mark_initial_scan_completed'), \
patch.object(initialization_service, '_load_series_into_memory'), \
patch('src.server.services.anime_service.sync_series_from_data_files'):
patch('src.server.services.anime_service.sync_legacy_series_to_db'):
mock_progress = AsyncMock()
result = await initialization_service.perform_initial_setup(mock_progress)
@@ -456,7 +456,7 @@ class TestInitialSetupWorkflow:
with patch.object(initialization_service, '_check_initial_scan_status', return_value=False), \
patch.object(initialization_service, '_validate_anime_directory', return_value=True), \
patch.object(initialization_service, '_sync_anime_folders', side_effect=OSError("Disk error")), \
patch('src.server.services.anime_service.sync_series_from_data_files'):
patch('src.server.services.anime_service.sync_legacy_series_to_db'):
result = await initialization_service.perform_initial_setup()
@@ -469,7 +469,7 @@ class TestInitialSetupWorkflow:
with patch.object(initialization_service, '_check_initial_scan_status', return_value=False), \
patch.object(initialization_service, '_validate_anime_directory', return_value=True), \
patch.object(initialization_service, '_sync_anime_folders', side_effect=RuntimeError("DB error")), \
patch('src.server.services.anime_service.sync_series_from_data_files'):
patch('src.server.services.anime_service.sync_legacy_series_to_db'):
result = await initialization_service.perform_initial_setup()