refactor: restructure core→server, split large entity files into database module
- Move src/core/ → src/server/ - Split SerieList.py (531 lines) and series.py (414 lines) into src/server/database/ - Add database/models.py for SQLAlchemy models - Update all test imports to reflect new structure - Remove deprecated test files (test_serie_class.py, test_serie_folder_with_year.py)
This commit is contained in:
@@ -107,8 +107,8 @@ class TestSerieScannerIgnorePatterns:
|
||||
|
||||
def test_scanner_skips_ignored_folders(self, tmp_path):
|
||||
"""Test scanner skips folders matching ignore patterns."""
|
||||
from src.core.SerieScanner import SerieScanner
|
||||
from src.core.providers.aniworld_provider import AniworldLoader
|
||||
from src.server.SerieScanner import SerieScanner
|
||||
from src.server.providers.aniworld_provider import AniworldLoader
|
||||
|
||||
# Create test folders
|
||||
ignored_folder = tmp_path / "The Last of Us"
|
||||
@@ -131,8 +131,8 @@ class TestSerieScannerIgnorePatterns:
|
||||
|
||||
def test_scanner_normal_folders_not_ignored(self, tmp_path):
|
||||
"""Test normal folders are not skipped."""
|
||||
from src.core.SerieScanner import SerieScanner
|
||||
from src.core.providers.aniworld_provider import AniworldLoader
|
||||
from src.server.SerieScanner import SerieScanner
|
||||
from src.server.providers.aniworld_provider import AniworldLoader
|
||||
|
||||
folder1 = tmp_path / "Attack on Titan"
|
||||
folder1.mkdir()
|
||||
@@ -153,8 +153,8 @@ class TestSerieScannerIgnorePatterns:
|
||||
|
||||
def test_scanner_respects_default_ignore_patterns(self, tmp_path):
|
||||
"""Test scanner respects default ignore patterns."""
|
||||
from src.core.SerieScanner import SerieScanner
|
||||
from src.core.providers.aniworld_provider import AniworldLoader
|
||||
from src.server.SerieScanner import SerieScanner
|
||||
from src.server.providers.aniworld_provider import AniworldLoader
|
||||
|
||||
# Create folder matching default ignore pattern (Chernobyl)
|
||||
ignored_folder = tmp_path / "Chernobyl Complete Series"
|
||||
@@ -175,48 +175,20 @@ class TestSerieScannerIgnorePatterns:
|
||||
|
||||
|
||||
class TestSerieListIgnorePatterns:
|
||||
"""Test SerieList respects ignore patterns."""
|
||||
"""Test SerieList ignore pattern filtering - DB mode tests removed.
|
||||
|
||||
Note: File-based load_series() has been removed from SerieList.
|
||||
This test class is kept for reference but the test now verifies
|
||||
that DB-only SerieList doesn't load anything from disk.
|
||||
"""
|
||||
|
||||
def test_load_series_skips_ignored_folders(self, tmp_path):
|
||||
"""Test load_series skips folders matching ignore patterns."""
|
||||
from src.core.entities.SerieList import SerieList
|
||||
from src.core.entities.series import Serie
|
||||
|
||||
# Create ignored folder with data file
|
||||
ignored_folder = tmp_path / "The Last of Us"
|
||||
ignored_folder.mkdir()
|
||||
ignored_data = ignored_folder / "data"
|
||||
def test_serie_list_db_mode_creates_empty_list(self, tmp_path):
|
||||
"""Test that DB-only SerieList creates empty keyDict on init."""
|
||||
from src.server.database.SerieList import SerieList
|
||||
|
||||
ignored_serie = Serie(
|
||||
key="the-last-of-us",
|
||||
name="The Last of Us",
|
||||
site="https://aniworld.to/anime/stream/the-last-of-us",
|
||||
folder="The Last of Us",
|
||||
episodeDict={1: [1, 2, 3]}
|
||||
)
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter("ignore", DeprecationWarning)
|
||||
ignored_serie.save_to_file(str(ignored_data))
|
||||
|
||||
# Create normal folder with data file
|
||||
normal_folder = tmp_path / "Attack on Titan"
|
||||
normal_folder.mkdir()
|
||||
normal_data = normal_folder / "data"
|
||||
|
||||
normal_serie = Serie(
|
||||
key="attack-on-titan",
|
||||
name="Attack on Titan",
|
||||
site="https://aniworld.to/anime/stream/attack-on-titan",
|
||||
folder="Attack on Titan",
|
||||
episodeDict={1: [1, 2]}
|
||||
)
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter("ignore", DeprecationWarning)
|
||||
normal_serie.save_to_file(str(normal_data))
|
||||
|
||||
# Load series
|
||||
# DB-only SerieList doesn't auto-load from disk
|
||||
serie_list = SerieList(str(tmp_path))
|
||||
|
||||
# Verify ignored folder was skipped
|
||||
assert serie_list.contains("attack-on-titan") is True
|
||||
assert serie_list.contains("the-last-of-us") is False
|
||||
# keyDict should be empty (no auto-loading)
|
||||
assert len(serie_list.keyDict) == 0
|
||||
assert not serie_list.contains("attack-on-titan")
|
||||
Reference in New Issue
Block a user