test: add tests for scheduled folder scan and startup NFO repair removal

Add comprehensive test coverage for Tasks 1.1–1.5 and 2.1:

- test_scheduler_config_model.py: folder_scan_enabled defaults, explicit
  values, backward compatibility with old configs, serialization roundtrip
- test_folder_scan_service.py (new): prerequisites, NFO repair integration,
  folder rename integration, poster check/download, semaphore values,
  NFO thumb URL extraction, full end-to-end scan flow
- test_scheduler_service.py: scheduler _perform_rescan integration with
  folder_scan_enabled (called when enabled, skipped when disabled, error
  handling and broadcasting), folder_scan_enabled in get_status output
- test_nfo_repair_startup.py: verify perform_nfo_repair_scan is NOT called
  during FastAPI lifespan startup and IS called from FolderScanService

All 90 tests pass.
This commit is contained in:
2026-05-13 09:43:34 +02:00
parent 756731cd5d
commit 9c0f7ce08d
3 changed files with 727 additions and 3 deletions

View File

@@ -113,8 +113,36 @@ class TestSchedulerConfigBackwardCompat:
assert config.interval_minutes == 30
class TestSchedulerConfigFolderScanEnabled:
"""3.8 folder_scan_enabled field (Task 1.1)."""
def test_default_folder_scan_enabled(self) -> None:
config = SchedulerConfig()
assert config.folder_scan_enabled is False
def test_set_folder_scan_enabled_true(self) -> None:
config = SchedulerConfig(folder_scan_enabled=True)
assert config.folder_scan_enabled is True
def test_set_folder_scan_enabled_false(self) -> None:
config = SchedulerConfig(folder_scan_enabled=False)
assert config.folder_scan_enabled is False
def test_backward_compat_missing_field(self) -> None:
"""Old configs without folder_scan_enabled load successfully."""
dumped = {
"enabled": True,
"interval_minutes": 60,
"schedule_time": "03:00",
"schedule_days": ALL_DAYS,
"auto_download_after_rescan": False,
}
config = SchedulerConfig(**dumped)
assert config.folder_scan_enabled is False
class TestSchedulerConfigSerialisation:
"""3.8 Serialisation roundtrip."""
"""3.9 Serialisation roundtrip."""
def test_roundtrip(self) -> None:
original = SchedulerConfig(
@@ -123,6 +151,7 @@ class TestSchedulerConfigSerialisation:
schedule_time="04:30",
schedule_days=["mon", "wed", "fri"],
auto_download_after_rescan=True,
folder_scan_enabled=True,
)
dumped = original.model_dump()
restored = SchedulerConfig(**dumped)