Cover-Embedding: frontcover.jpg/backcover.jpg als Standard-Konvention
cover: find_cover() sucht frontcover.jpg/.png und backcover.jpg/.png; copy_covers() speichert als frontcover.jpg / backcover.jpg tagger: embed_album_cover() bettet Frontcover in alle Tracks ein cli: apply und process rufen embed_album_cover() nach copy_covers() auf tests: TestFindCover mit 7 Tests (jpg, png, Symlink, Priorität, Negativ) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
c9152cf19f
commit
3fa6237f94
4 changed files with 102 additions and 9 deletions
45
tests/test_cover.py
Normal file
45
tests/test_cover.py
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
"""Tests für Cover-Funktionen."""
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from musiksammlung.cover import find_cover
|
||||
|
||||
|
||||
class TestFindCover:
|
||||
"""Tests für find_cover."""
|
||||
|
||||
def test_finds_frontcover_jpg(self, tmp_path: Path) -> None:
|
||||
(tmp_path / "frontcover.jpg").touch()
|
||||
assert find_cover(tmp_path, "front") == tmp_path / "frontcover.jpg"
|
||||
|
||||
def test_finds_frontcover_png(self, tmp_path: Path) -> None:
|
||||
(tmp_path / "frontcover.png").touch()
|
||||
assert find_cover(tmp_path, "front") == tmp_path / "frontcover.png"
|
||||
|
||||
def test_jpg_preferred_over_png(self, tmp_path: Path) -> None:
|
||||
(tmp_path / "frontcover.jpg").touch()
|
||||
(tmp_path / "frontcover.png").touch()
|
||||
# .jpg wird zuerst geprüft
|
||||
assert find_cover(tmp_path, "front") == tmp_path / "frontcover.jpg"
|
||||
|
||||
def test_finds_backcover(self, tmp_path: Path) -> None:
|
||||
(tmp_path / "backcover.jpg").touch()
|
||||
assert find_cover(tmp_path, "back") == tmp_path / "backcover.jpg"
|
||||
|
||||
def test_returns_none_if_missing(self, tmp_path: Path) -> None:
|
||||
assert find_cover(tmp_path, "front") is None
|
||||
assert find_cover(tmp_path, "back") is None
|
||||
|
||||
def test_follows_symlink(self, tmp_path: Path) -> None:
|
||||
real = tmp_path / "original.jpg"
|
||||
real.touch()
|
||||
link = tmp_path / "frontcover.jpg"
|
||||
link.symlink_to(real)
|
||||
assert find_cover(tmp_path, "front") == link
|
||||
|
||||
def test_ignores_wrong_names(self, tmp_path: Path) -> None:
|
||||
(tmp_path / "cover.jpg").touch()
|
||||
(tmp_path / "back.jpg").touch()
|
||||
assert find_cover(tmp_path, "front") is None
|
||||
Loading…
Add table
Add a link
Reference in a new issue