Discover Serato smart crate definitions
This commit is contained in:
+34
-1
@@ -6,6 +6,7 @@ from serato_doctor.crate_parser import (
|
||||
classify_crate,
|
||||
clean_path,
|
||||
load_crate,
|
||||
load_library_crates,
|
||||
parse_crate,
|
||||
parse_crates,
|
||||
path_markers,
|
||||
@@ -92,7 +93,7 @@ def test_parse_crates_reuses_configured_roots_for_every_crate(tmp_path):
|
||||
("relative_path", "expected"),
|
||||
[
|
||||
("_Serato_/Subcrates/House.crate", CrateKind.STATIC),
|
||||
("_Serato_/Smartcrates/Warmup.crate", CrateKind.SMART),
|
||||
("_Serato_/SmartCrates/Warmup.scrate", CrateKind.SMART),
|
||||
("_Serato_/Subcrates/Compatible by key.crate", CrateKind.SMART),
|
||||
("fixtures/Unknown.crate", CrateKind.UNKNOWN),
|
||||
],
|
||||
@@ -101,3 +102,35 @@ def test_classify_crate_uses_provenance_and_known_dynamic_name(
|
||||
tmp_path, relative_path, expected
|
||||
):
|
||||
assert classify_crate(tmp_path / relative_path) is expected
|
||||
|
||||
|
||||
def test_smart_crate_preserves_encoded_hierarchy(tmp_path):
|
||||
crate_path = (
|
||||
tmp_path / "_Serato_" / "SmartCrates" / "Compatible by key≫≫10A.scrate"
|
||||
)
|
||||
crate_path.parent.mkdir(parents=True)
|
||||
crate_path.write_bytes(b"")
|
||||
crate = load_crate(crate_path)
|
||||
|
||||
assert crate.kind is CrateKind.SMART
|
||||
assert crate.hierarchy == ("Compatible by key", "10A")
|
||||
assert crate.display_name == "10A"
|
||||
assert crate.is_smart_definition
|
||||
|
||||
|
||||
def test_load_library_crates_discovers_scrate_definitions(tmp_path):
|
||||
smart_folder = tmp_path / "SmartCrates"
|
||||
static_folder = tmp_path / "Subcrates"
|
||||
smart_folder.mkdir()
|
||||
static_folder.mkdir()
|
||||
(smart_folder / "New EDM.scrate").write_bytes(b"")
|
||||
(smart_folder / "Re-Drums.scrate").write_bytes(b"")
|
||||
(static_folder / "House.crate").write_bytes(b"")
|
||||
|
||||
crates = load_library_crates(tmp_path)
|
||||
|
||||
assert [(crate.path.name, crate.kind) for crate in crates] == [
|
||||
("New EDM.scrate", CrateKind.SMART),
|
||||
("Re-Drums.scrate", CrateKind.SMART),
|
||||
("House.crate", CrateKind.STATIC),
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user