chore: apply pending code updates
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
"""Unit test for NFOService.update_tvshow_nfo() - tests XML parsing logic."""
|
||||
|
||||
import asyncio
|
||||
import logging
|
||||
import shutil
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
@@ -8,6 +9,8 @@ from pathlib import Path
|
||||
import pytest
|
||||
from lxml import etree
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
from src.core.services.nfo_service import NFOService
|
||||
from src.core.services.tmdb_client import TMDBAPIError
|
||||
|
||||
@@ -51,7 +54,7 @@ def test_parse_nfo_with_uniqueid():
|
||||
break
|
||||
|
||||
assert tmdb_id == 1429, f"Expected TMDB ID 1429, got {tmdb_id}"
|
||||
print(f"✓ Successfully parsed TMDB ID from uniqueid: {tmdb_id}")
|
||||
logger.info("Successfully parsed TMDB ID from uniqueid: %s", tmdb_id)
|
||||
|
||||
finally:
|
||||
shutil.rmtree(temp_dir)
|
||||
@@ -92,7 +95,7 @@ def test_parse_nfo_with_tmdbid_element():
|
||||
tmdb_id = int(tmdbid_elem.text)
|
||||
|
||||
assert tmdb_id == 12345, f"Expected TMDB ID 12345, got {tmdb_id}"
|
||||
print(f"✓ Successfully parsed TMDB ID from tmdbid element: {tmdb_id}")
|
||||
logger.info("Successfully parsed TMDB ID from tmdbid element: %s", tmdb_id)
|
||||
|
||||
finally:
|
||||
shutil.rmtree(temp_dir)
|
||||
@@ -131,7 +134,7 @@ def test_parse_nfo_without_tmdb_id():
|
||||
tmdb_id = int(tmdbid_elem.text)
|
||||
|
||||
assert tmdb_id is None, "Should not have found TMDB ID"
|
||||
print("✓ Correctly identified NFO without TMDB ID")
|
||||
logger.info("Correctly identified NFO without TMDB ID")
|
||||
|
||||
finally:
|
||||
shutil.rmtree(temp_dir)
|
||||
@@ -157,22 +160,23 @@ def test_parse_invalid_xml():
|
||||
tree = etree.parse(str(nfo_path))
|
||||
assert False, "Should have raised XMLSyntaxError"
|
||||
except etree.XMLSyntaxError:
|
||||
print("✓ Correctly raised XMLSyntaxError for invalid XML")
|
||||
logger.info("Correctly raised XMLSyntaxError for invalid XML")
|
||||
|
||||
finally:
|
||||
shutil.rmtree(temp_dir)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("Testing NFO XML parsing logic...")
|
||||
print()
|
||||
|
||||
logging.basicConfig(level=logging.INFO, format="%(message)s")
|
||||
logger.info("Testing NFO XML parsing logic...")
|
||||
logger.info("")
|
||||
|
||||
test_parse_nfo_with_uniqueid()
|
||||
test_parse_nfo_with_tmdbid_element()
|
||||
test_parse_nfo_without_tmdb_id()
|
||||
test_parse_invalid_xml()
|
||||
|
||||
print()
|
||||
print("=" * 60)
|
||||
print("✓ ALL TESTS PASSED")
|
||||
print("=" * 60)
|
||||
|
||||
logger.info("")
|
||||
logger.info("%s", "=" * 60)
|
||||
logger.info("ALL TESTS PASSED")
|
||||
logger.info("%s", "=" * 60)
|
||||
|
||||
@@ -5,11 +5,14 @@ each other. The background loader should process multiple series simultaneously
|
||||
rather than sequentially.
|
||||
"""
|
||||
import asyncio
|
||||
import logging
|
||||
from datetime import datetime, timezone
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
from src.server.services.background_loader_service import (
|
||||
BackgroundLoaderService,
|
||||
LoadingStatus,
|
||||
@@ -162,9 +165,9 @@ async def test_parallel_anime_additions(
|
||||
f"(indicating sequential processing)"
|
||||
)
|
||||
|
||||
print(f"✓ Parallel execution verified:")
|
||||
print(f" - Start time difference: {start_diff:.3f}s")
|
||||
print(f" - Total duration: {total_duration:.3f}s")
|
||||
logger.info("Parallel execution verified")
|
||||
logger.info("Start time difference: %.3fs", start_diff)
|
||||
logger.info("Total duration: %.3fs", total_duration)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
||||
Reference in New Issue
Block a user