feat: Add NFO configuration settings (Task 7)
- Added NFOConfig model with TMDB API key, auto-create, media downloads, image size settings - Created NFO settings section in UI with form fields and validation - Implemented nfo-config.js module for loading, saving, and testing TMDB connection - Added TMDB API key validation endpoint (POST /api/config/tmdb/validate) - Integrated NFO config into AppConfig and ConfigUpdate models - Added 5 unit tests for NFO config model validation - Added API test for TMDB validation endpoint - All 16 config model tests passing, all 10 config API tests passing - Documented in docs/task7_status.md (100% complete)
This commit is contained in:
@@ -191,3 +191,19 @@ async def test_config_persistence(authenticated_client, mock_config_service):
|
||||
resp2 = await authenticated_client.get("/api/config")
|
||||
assert resp2.status_code == 200
|
||||
assert resp2.json() == initial
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_tmdb_validation_endpoint_exists(authenticated_client):
|
||||
"""Test TMDB validation endpoint exists and is callable."""
|
||||
resp = await authenticated_client.post(
|
||||
"/api/config/tmdb/validate",
|
||||
json={"api_key": ""}
|
||||
)
|
||||
|
||||
assert resp.status_code == 200
|
||||
data = resp.json()
|
||||
assert "valid" in data
|
||||
assert "message" in data
|
||||
assert data["valid"] is False # Empty key should be invalid
|
||||
assert "required" in data["message"].lower()
|
||||
|
||||
@@ -4,6 +4,7 @@ from src.server.models.config import (
|
||||
AppConfig,
|
||||
ConfigUpdate,
|
||||
LoggingConfig,
|
||||
NFOConfig,
|
||||
SchedulerConfig,
|
||||
ValidationResult,
|
||||
)
|
||||
@@ -53,3 +54,56 @@ def test_backup_and_validation():
|
||||
res2 = cfg.validate_config()
|
||||
assert res2.valid is False
|
||||
assert any("backup.path" in e for e in res2.errors)
|
||||
|
||||
|
||||
def test_nfo_config_defaults():
|
||||
"""Test NFO configuration defaults."""
|
||||
nfo = NFOConfig()
|
||||
assert nfo.tmdb_api_key is None
|
||||
assert nfo.auto_create is False
|
||||
assert nfo.update_on_scan is False
|
||||
assert nfo.download_poster is True
|
||||
assert nfo.download_logo is True
|
||||
assert nfo.download_fanart is True
|
||||
assert nfo.image_size == "original"
|
||||
|
||||
|
||||
def test_nfo_config_image_size_validation():
|
||||
"""Test NFO image size validation."""
|
||||
# Valid sizes
|
||||
nfo1 = NFOConfig(image_size="original")
|
||||
assert nfo1.image_size == "original"
|
||||
|
||||
nfo2 = NFOConfig(image_size="w500")
|
||||
assert nfo2.image_size == "w500"
|
||||
|
||||
# Invalid size
|
||||
with pytest.raises(ValueError, match="invalid image size"):
|
||||
NFOConfig(image_size="invalid")
|
||||
|
||||
|
||||
def test_appconfig_includes_nfo():
|
||||
"""Test that AppConfig includes NFO configuration."""
|
||||
cfg = AppConfig()
|
||||
assert cfg.nfo is not None
|
||||
assert isinstance(cfg.nfo, NFOConfig)
|
||||
assert cfg.nfo.auto_create is False
|
||||
|
||||
|
||||
def test_config_update_with_nfo():
|
||||
"""Test ConfigUpdate can update NFO settings."""
|
||||
base = AppConfig()
|
||||
|
||||
# Create NFO config update
|
||||
nfo_config = NFOConfig(
|
||||
tmdb_api_key="test_key_123",
|
||||
auto_create=True,
|
||||
image_size="w500"
|
||||
)
|
||||
|
||||
upd = ConfigUpdate(nfo=nfo_config)
|
||||
new = upd.apply_to(base)
|
||||
|
||||
assert new.nfo.tmdb_api_key == "test_key_123"
|
||||
assert new.nfo.auto_create is True
|
||||
assert new.nfo.image_size == "w500"
|
||||
|
||||
Reference in New Issue
Block a user