33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
from audiobooksorter.cli import _format_dry_run
|
|
from audiobooksorter.ingest import load_library
|
|
from audiobooksorter.sorter import sort_by_series
|
|
|
|
|
|
def test_loads_directory_without_metadata_files() -> None:
|
|
records = load_library(Path("testdata"))
|
|
|
|
assert len(records) == 14
|
|
series_names = {record.series for record in records}
|
|
assert {"All the Skills", "Battle Mage Farmer", "The Wandering Inn"} <= series_names
|
|
|
|
battle_indexes = sorted(
|
|
record.series_index for record in records if record.series == "Battle Mage Farmer"
|
|
)
|
|
assert battle_indexes == [1.0, 2.0, 3.0, 4.0]
|
|
|
|
|
|
def test_dry_run_formats_preview() -> None:
|
|
records = sort_by_series(load_library(Path("testdata")))
|
|
|
|
preview = _format_dry_run(records)
|
|
|
|
assert "Dry run (no files written)" in preview
|
|
assert "Seth Ring / Battle Mage Farmer" in preview
|
|
assert "Seth Ring / Battle Mage Farmer / Book 1" in preview
|
|
assert "PirateAba / The Wandering Inn" in preview
|
|
assert "PirateAba / The Wandering Inn / Book 1" in preview
|