soulsync/tests/test_import_filename.py
Antti Kettunen 0bbf44809f
Move the import flows and related post-processing pipelines into separate modules
- Extract the import pipeline, album import, staging, path, file ops, guards, runtime state, side effects, and metadata enrichment out of .
- Canonicalize the refactored import path around  and remove legacy , , , and  request shapes from the import endpoints.
- Make album and track metadata lookups follow the configured provider priority instead of hard-coding Spotify, while still falling back when needed.
- Update the import routes and frontend payloads to use the new core helpers.
- Add coverage for the extracted helpers and the refactored import flows.

PS. apologies to anyone who might check this commit out - the intention was to start small, but things kinda snowballed out of control at some point since the logic just kept going on and on, and everything kinda had to be changed all at once for it all to make any sense
2026-04-27 19:54:43 +03:00

33 lines
1.1 KiB
Python

import pytest
from core.import_filename import parse_filename_metadata
@pytest.mark.parametrize(
"filename,expected",
[
(
"01 - Artist One - Title One.mp3",
{"artist": "Artist One", "title": "Title One", "album": "", "track_number": 1},
),
(
"Artist Two - Title Two.flac",
{"artist": "Artist Two", "title": "Title Two", "album": "", "track_number": None},
),
(
r"Artist Three\Album Three\03 - Title Three.ogg",
{"artist": "", "title": "Title Three", "album": "Album Three", "track_number": 3},
),
(
"Loose Song.wav",
{"artist": "", "title": "Loose Song", "album": "", "track_number": None},
),
],
)
def test_parse_filename_metadata_handles_common_patterns(filename, expected):
parsed = parse_filename_metadata(filename)
assert parsed["artist"] == expected["artist"]
assert parsed["title"] == expected["title"]
assert parsed["album"] == expected["album"]
assert parsed["track_number"] == expected["track_number"]