chore: sprint cleanup — language unification, parser unification, fossils removal
Several weeks of work accumulated without being committed. Grouped here for clarity; see CHANGELOG.md [Unreleased] for the user-facing summary. Highlights ---------- P1 #2 — ISO 639-2/B canonical migration - New Language VO + LanguageRegistry (alfred/domain/shared/knowledge/). - iso_languages.yaml as single source of truth for language codes. - SubtitleKnowledgeBase now delegates lookup to LanguageRegistry; subtitles.yaml only declares subtitle-specific tokens (vostfr, vf, vff, …). - SubtitlePreferences default → ["fre", "eng"]; subtitle filenames written as {iso639_2b}.srt (legacy fr.srt still read via alias). - Scanner: dropped _LANG_KEYWORDS / _SDH_TOKENS / _FORCED_TOKENS / SUBTITLE_EXTENSIONS hardcoded dicts. - Fixed: 'hi' token no longer marks SDH (conflicted with Hindi alias). - Added settings.min_movie_size_bytes (was a module constant). P1 #3 — Release parser unification + data-driven tokenizer - parse_release() is now the single source of truth for release-name parsing. - alfred/knowledge/release/separators.yaml declares the token separators used by the tokenizer (., space, [, ], (, ), _). New conventions can be added without code changes. - Tokenizer now splits on any configured separator instead of name.split('.'). Releases like 'The Father (2020) [1080p] [WEBRip] [5.1] [YTS.MX]' parse via the direct path without sanitization fallback. - Site-tag extraction always runs first; well-formedness only rejects truly forbidden chars. - _parse_season_episode() extended with NxNN / NxNNxNN alt forms. - Removed dead helpers: _sanitize, _normalize. Domain cleanup - Deleted fossil services with zero production callers: alfred/domain/movies/services.py alfred/domain/tv_shows/services.py alfred/domain/subtitles/services.py (replaced by subtitles/services/ package) alfred/domain/subtitles/repositories.py - Split monolithic subtitle services into a package (identifier, matcher, placer, pattern_detector, utils) + dedicated knowledge/ package. - MediaInfo split into dedicated package (alfred/domain/shared/media/: audio, video, subtitle, info, matching). Persistence cleanup - Removed dead JSON repositories (movie/subtitle/tvshow_repository.py). Tests - Major expansion of the test suite organized to mirror the source tree. - Removed obsolete *_edge_cases test files superseded by structured tests. - Suite: 990 passed, 8 skipped. Misc - .gitignore: exclude env_backup/ and *.bak. - Adjustments across agent/llm, app.py, application/filesystem, and infrastructure/filesystem to align with the new domain layout.
This commit is contained in:
+35
-12
@@ -1,8 +1,23 @@
|
||||
"""Pytest configuration and shared fixtures."""
|
||||
"""Shared pytest fixtures for the Alfred test suite.
|
||||
|
||||
Provides three categories of fixtures used across all test packages:
|
||||
|
||||
1. **Isolation** — ``mock_memory_storage_dir`` (autouse) and ``temp_dir``
|
||||
ensure no test ever touches the real ``data/`` directory.
|
||||
2. **Memory builders** — ``memory``, ``memory_with_config``,
|
||||
``memory_with_history``, ``memory_with_search_results``,
|
||||
``memory_with_library`` produce ``Memory`` instances in known states for
|
||||
tests that consume the global singleton.
|
||||
3. **Test doubles** — ``mock_llm``, ``mock_llm_with_tool_call``,
|
||||
``mock_tmdb_client``, ``mock_knaben_client``, ``mock_qbittorrent_client``,
|
||||
``mock_deepseek``, and the filesystem fixture ``real_folder``.
|
||||
|
||||
All memory fixtures use the current component-based LTM API:
|
||||
``ltm.library_paths.set(collection, path)`` and
|
||||
``ltm.workspace.download``/``torrent``. Legacy flat attributes
|
||||
(``movie_folder``, ``tvshow_folder``, ``download_folder``) no longer exist.
|
||||
"""
|
||||
|
||||
# TODO: Moved directory, should not be necessary anymore but need to check !!
|
||||
# Ajouter le dossier parent (brain) au PYTHONPATH
|
||||
# sys.path.insert(0, str(Path(__file__).parent.parent))
|
||||
import shutil
|
||||
import sys
|
||||
import tempfile
|
||||
@@ -49,11 +64,15 @@ def memory(temp_dir):
|
||||
|
||||
@pytest.fixture
|
||||
def memory_with_config(memory):
|
||||
"""Memory with pre-configured folders."""
|
||||
memory.ltm.download_folder = "/tmp/downloads"
|
||||
memory.ltm.movie_folder = "/tmp/movies"
|
||||
memory.ltm.tvshow_folder = "/tmp/tvshows"
|
||||
memory.ltm.torrent_folder = "/tmp/torrents"
|
||||
"""Memory with pre-configured workspace and library paths.
|
||||
|
||||
Uses the current component-based LTM API. The values are arbitrary
|
||||
placeholders — tests that care about the actual paths should override.
|
||||
"""
|
||||
memory.ltm.workspace.download = "/tmp/downloads"
|
||||
memory.ltm.workspace.torrent = "/tmp/torrents"
|
||||
memory.ltm.library_paths.set("movies", "/tmp/movies")
|
||||
memory.ltm.library_paths.set("tv_shows", "/tmp/tvshows")
|
||||
return memory
|
||||
|
||||
|
||||
@@ -105,8 +124,12 @@ def memory_with_history(memory):
|
||||
|
||||
@pytest.fixture
|
||||
def memory_with_library(memory):
|
||||
"""Memory with movies in library."""
|
||||
memory.ltm.library["movies"] = [
|
||||
"""Memory pre-populated with movies and TV shows.
|
||||
|
||||
Uses the current ``Library`` component (``library.movies`` and
|
||||
``library.tv_shows`` lists of dicts).
|
||||
"""
|
||||
memory.ltm.library.movies = [
|
||||
{
|
||||
"imdb_id": "tt1375666",
|
||||
"title": "Inception",
|
||||
@@ -124,7 +147,7 @@ def memory_with_library(memory):
|
||||
"added_at": "2024-01-16T14:20:00",
|
||||
},
|
||||
]
|
||||
memory.ltm.library["tv_shows"] = [
|
||||
memory.ltm.library.tv_shows = [
|
||||
{
|
||||
"imdb_id": "tt0944947",
|
||||
"title": "Game of Thrones",
|
||||
|
||||
Reference in New Issue
Block a user