add program files

This commit is contained in:
2025-11-16 10:00:56 +01:00
parent 4a019c37c2
commit 4519d722bc
23 changed files with 1205 additions and 0 deletions
+45
View File
@@ -0,0 +1,45 @@
from __future__ import annotations
from pathlib import Path
from audiobooksorter.export import write_sorted
from audiobooksorter.ingest import AudiobookRecord
def test_write_sorted_copies_source_directories(tmp_path: Path) -> None:
source = tmp_path / "library"
book_dir = source / "Brandon" / "Mistborn1"
book_dir.mkdir(parents=True)
(book_dir / "chapter1.mp3").write_text("audio-data", encoding="utf-8")
destination = tmp_path / "sorted"
record = AudiobookRecord(
title="The Final Empire",
series="Mistborn",
series_index=1,
author="Brandon Sanderson",
source_path=book_dir,
)
write_sorted([record], destination)
expected = destination / "Brandon Sanderson" / "Mistborn" / "Book 1 - The Final Empire"
assert (expected / "chapter1.mp3").read_text(encoding="utf-8") == "audio-data"
def test_write_sorted_creates_metadata_when_missing_source(tmp_path: Path) -> None:
destination = tmp_path / "sorted"
record = AudiobookRecord(
title="",
series=None,
series_index=None,
author="",
source_path=None,
)
write_sorted([record], destination)
expected = destination / "Unknown Author" / "Untitled"
metadata = expected / "metadata.json"
assert metadata.exists()
assert '"title": ""' in metadata.read_text(encoding="utf-8")