mirror of
https://github.com/darkzoul5/YoutubePlaylistSync.git
synced 2026-09-23 06:42:26 +03:00
Refactor test configurations and enhance testing framework
- Replace TempConfig with DummyConfig across tests for consistency - Introduce unit tests workflow configuration - Add pytest configuration for standardized test discovery - Implement comprehensive tests for config loading and downloader behavior - Clean up unused temp_config.py and related references
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
from pathlib import Path
|
||||
|
||||
from ytplaylist.downloader import PlaylistDownloader
|
||||
from tests.dummy_config import DummyConfig
|
||||
|
||||
|
||||
def test_sanitize_title_and_get_file_path(tmp_path):
|
||||
cfg = DummyConfig()
|
||||
playlist = {"url": None, "save_path": str(tmp_path)}
|
||||
dl = PlaylistDownloader(cfg, playlist, 0)
|
||||
|
||||
# illegal chars should be replaced and trimmed; fallback_id used when title becomes empty
|
||||
title = ' My: <>:"/\\|?*Title '
|
||||
safe = dl.sanitize_title(title, "ABC123")
|
||||
# ensure no illegal characters remain
|
||||
assert all(c not in safe for c in dl.illegal_chars)
|
||||
|
||||
# empty title should return fallback id
|
||||
assert dl.sanitize_title(" ", "FALLBACK") == "FALLBACK"
|
||||
|
||||
# get_file_path uses save_path and zero-padded index
|
||||
path = dl.get_file_path(5, "SongName")
|
||||
assert isinstance(path, Path)
|
||||
assert path.name.startswith("005 - SongName")
|
||||
Reference in New Issue
Block a user