refactor(analyzer): improve analyzer pipeline module (#1542)
* rename steps to pipeline module * move pipeline entrypoint to pipeline module * rename steps test module to pipeline * fix paths after renames * move step protocol to pipeline * create pipeline status enum * use Protocol from typing extensions * Fix linting
This commit is contained in:
parent
74c8d20284
commit
cba905e367
18 changed files with 34 additions and 26 deletions
48
analyzer/tests/pipeline/pipeline_test.py
Normal file
48
analyzer/tests/pipeline/pipeline_test.py
Normal file
|
@ -0,0 +1,48 @@
|
|||
import datetime
|
||||
import os
|
||||
from queue import Queue
|
||||
|
||||
import pytest
|
||||
|
||||
from libretime_analyzer.pipeline import Pipeline
|
||||
|
||||
from ..conftest import AUDIO_FILENAME, AUDIO_IMPORT_DEST
|
||||
|
||||
|
||||
def test_run_analysis(src_dir, dest_dir):
|
||||
queue = Queue()
|
||||
Pipeline.run_analysis(
|
||||
queue,
|
||||
os.path.join(src_dir, AUDIO_FILENAME),
|
||||
dest_dir,
|
||||
AUDIO_FILENAME,
|
||||
"file",
|
||||
"",
|
||||
)
|
||||
metadata = queue.get()
|
||||
|
||||
assert metadata["track_title"] == "Test Title"
|
||||
assert metadata["artist_name"] == "Test Artist"
|
||||
assert metadata["album_title"] == "Test Album"
|
||||
assert metadata["year"] == "1999"
|
||||
assert metadata["genre"] == "Test Genre"
|
||||
assert metadata["mime"] == "audio/mp3"
|
||||
assert metadata["length_seconds"] == pytest.approx(15.0, abs=0.1)
|
||||
assert metadata["length"] == str(
|
||||
datetime.timedelta(seconds=metadata["length_seconds"])
|
||||
)
|
||||
assert os.path.exists(os.path.join(dest_dir, AUDIO_IMPORT_DEST))
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"params,exception",
|
||||
[
|
||||
((Queue(), "", "", ""), TypeError),
|
||||
((Queue(), "", "", ""), TypeError),
|
||||
((Queue(), "", "", ""), TypeError),
|
||||
((Queue(), "", "", ""), TypeError),
|
||||
],
|
||||
)
|
||||
def test_run_analysis_wrong_params(params, exception):
|
||||
with pytest.raises(exception):
|
||||
Pipeline.run_analysis(*params)
|
Loading…
Add table
Add a link
Reference in a new issue