29 lines
1000 B
Python
29 lines
1000 B
Python
import runpy
|
|
from pathlib import Path
|
|
|
|
from serato_doctor.crate_parser import parse_crates
|
|
from serato_doctor.models.library import Library
|
|
from serato_doctor.scanner import scan_audio
|
|
|
|
|
|
def test_generated_sample_library_has_expected_scenario(tmp_path):
|
|
generator_path = (
|
|
Path(__file__).parents[1] / "samples" / "small-library" / "generate.py"
|
|
)
|
|
build_sample = runpy.run_path(str(generator_path))["build_sample"]
|
|
sample_root = build_sample(tmp_path / "sample")
|
|
|
|
references = parse_crates(sample_root / "Serato" / "_Serato_" / "Subcrates")
|
|
tracks = scan_audio(sample_root / "Music")
|
|
results = Library.build(references, tracks).reconcile_by_filename()
|
|
missing = {
|
|
result.reference.filename
|
|
for result in results
|
|
if not result.exists_by_filename
|
|
}
|
|
|
|
assert len(list((sample_root / "Serato").rglob("*.crate"))) == 7
|
|
assert len(references) == 13
|
|
assert len(tracks) == 10
|
|
assert missing == {"Missing.mp3", "Old Name.mp3"}
|