test(analyzer): rename and remove unused imports
This commit is contained in:
parent
7aba20f1ac
commit
6a919a9805
|
@ -1,6 +1,5 @@
|
|||
import datetime
|
||||
import os
|
||||
import shutil
|
||||
from queue import Queue
|
||||
|
||||
import pytest
|
||||
|
|
|
@ -5,14 +5,14 @@ import pytest
|
|||
|
||||
from libretime_analyzer.steps.analyze_cuepoint import analyze_cuepoint
|
||||
|
||||
from ..fixtures import FILE_INVALID_DRM, FILES, Fixture
|
||||
from ..fixtures import FILE_INVALID_DRM, FILES
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"filepath,length,cuein,cueout",
|
||||
map(lambda i: (str(i.path), i.length, i.cuein, i.cueout), FILES),
|
||||
)
|
||||
def test_analyze(filepath, length, cuein, cueout):
|
||||
def test_analyze_cuepoint(filepath, length, cuein, cueout):
|
||||
metadata = analyze_cuepoint(filepath, dict())
|
||||
|
||||
assert metadata["length_seconds"] == pytest.approx(length, abs=0.1)
|
||||
|
@ -33,7 +33,7 @@ def test_analyze(filepath, length, cuein, cueout):
|
|||
assert float(metadata["cueout"]) == pytest.approx(cueout, abs=0.5)
|
||||
|
||||
|
||||
def test_analyze_missing_silan():
|
||||
def test_analyze_cuepoint_missing_silan():
|
||||
with patch(
|
||||
"libretime_analyzer.steps.analyze_cuepoint.SILAN_EXECUTABLE",
|
||||
"foobar",
|
||||
|
@ -41,11 +41,11 @@ def test_analyze_missing_silan():
|
|||
analyze_cuepoint(str(FILES[0].path), dict())
|
||||
|
||||
|
||||
def test_analyze_invalid_filepath():
|
||||
def test_analyze_cuepoint_invalid_filepath():
|
||||
with pytest.raises(KeyError):
|
||||
test_analyze("non-existent-file", None, None, None)
|
||||
test_analyze_cuepoint("non-existent-file", None, None, None)
|
||||
|
||||
|
||||
def test_analyze_invalid_wma():
|
||||
def test_analyze_cuepoint_invalid_wma():
|
||||
with pytest.raises(KeyError):
|
||||
test_analyze(FILE_INVALID_DRM, None, None, None)
|
||||
test_analyze_cuepoint(FILE_INVALID_DRM, None, None, None)
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
from datetime import timedelta
|
||||
from unittest import mock
|
||||
|
||||
import mutagen
|
||||
import pytest
|
||||
|
||||
from libretime_analyzer.steps.analyze_metadata import analyze_metadata
|
||||
|
||||
from ..fixtures import FILE_INVALID_DRM, FILE_INVALID_TXT, FILES_TAGGED, FixtureMeta
|
||||
from ..fixtures import FILE_INVALID_DRM, FILE_INVALID_TXT, FILES_TAGGED
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
@ -16,7 +12,7 @@ from ..fixtures import FILE_INVALID_DRM, FILE_INVALID_TXT, FILES_TAGGED, Fixture
|
|||
(("foo", 3), TypeError),
|
||||
],
|
||||
)
|
||||
def test_analyze_wrong_params(params, exception):
|
||||
def test_analyze_metadata_wrong_params(params, exception):
|
||||
with pytest.raises(exception):
|
||||
analyze_metadata(*params)
|
||||
|
||||
|
@ -25,7 +21,7 @@ def test_analyze_wrong_params(params, exception):
|
|||
"filepath,metadata",
|
||||
map(lambda i: (str(i.path), i.metadata), FILES_TAGGED),
|
||||
)
|
||||
def test_analyze(filepath: str, metadata: dict):
|
||||
def test_analyze_metadata(filepath: str, metadata: dict):
|
||||
found = analyze_metadata(filepath, dict())
|
||||
|
||||
# Mutagen does not support wav files yet
|
||||
|
@ -49,12 +45,12 @@ def test_analyze(filepath: str, metadata: dict):
|
|||
assert found == metadata
|
||||
|
||||
|
||||
def test_invalid_wma():
|
||||
def test_analyze_metadata_invalid_wma():
|
||||
metadata = analyze_metadata(str(FILE_INVALID_DRM), dict())
|
||||
assert metadata["mime"] == "audio/x-ms-wma"
|
||||
|
||||
|
||||
def test_unparsable_file():
|
||||
def test_analyze_metadata_unparsable_file():
|
||||
metadata = analyze_metadata(str(FILE_INVALID_TXT), dict())
|
||||
assert metadata == {
|
||||
"filesize": 10,
|
||||
|
|
|
@ -8,18 +8,18 @@ from libretime_analyzer.steps.analyze_playability import (
|
|||
analyze_playability,
|
||||
)
|
||||
|
||||
from ..fixtures import FILE_INVALID_DRM, FILES, Fixture
|
||||
from ..fixtures import FILE_INVALID_DRM, FILES
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"filepath",
|
||||
map(lambda i: str(i.path), FILES),
|
||||
)
|
||||
def test_analyze(filepath):
|
||||
def test_analyze_playability(filepath):
|
||||
analyze_playability(filepath, dict())
|
||||
|
||||
|
||||
def test_analyze_missing_liquidsoap():
|
||||
def test_analyze_playability_missing_liquidsoap():
|
||||
with patch(
|
||||
"libretime_analyzer.steps.analyze_playability.LIQUIDSOAP_EXECUTABLE",
|
||||
"foobar",
|
||||
|
@ -27,20 +27,20 @@ def test_analyze_missing_liquidsoap():
|
|||
analyze_playability(str(FILES[0].path), dict())
|
||||
|
||||
|
||||
def test_analyze_invalid_filepath():
|
||||
def test_analyze_playability_invalid_filepath():
|
||||
with pytest.raises(UnplayableFileError):
|
||||
test_analyze("non-existent-file")
|
||||
test_analyze_playability("non-existent-file")
|
||||
|
||||
|
||||
def test_analyze_invalid_wma():
|
||||
def test_analyze_playability_invalid_wma():
|
||||
# Liquisoap does not fail with wma files on buster, bullseye, focal
|
||||
if distro.codename() in ("buster", "bullseye", "focal"):
|
||||
return
|
||||
|
||||
with pytest.raises(UnplayableFileError):
|
||||
test_analyze(FILE_INVALID_DRM)
|
||||
test_analyze_playability(FILE_INVALID_DRM)
|
||||
|
||||
|
||||
def test_analyze_unknown():
|
||||
def test_analyze_playability_unknown():
|
||||
with pytest.raises(UnplayableFileError):
|
||||
test_analyze("https://www.google.com")
|
||||
test_analyze_playability("https://www.google.com")
|
||||
|
|
|
@ -11,12 +11,12 @@ from ..fixtures import FILE_INVALID_DRM, FILES, Fixture
|
|||
"filepath,replaygain",
|
||||
map(lambda i: (str(i.path), i.replaygain), FILES),
|
||||
)
|
||||
def test_analyze(filepath, replaygain):
|
||||
def test_analyze_replaygain(filepath, replaygain):
|
||||
metadata = analyze_replaygain(filepath, dict())
|
||||
assert metadata["replay_gain"] == pytest.approx(replaygain, abs=0.6)
|
||||
|
||||
|
||||
def test_analyze_missing_replaygain():
|
||||
def test_analyze_replaygain_missing_replaygain():
|
||||
with patch(
|
||||
"libretime_analyzer.steps.analyze_replaygain.REPLAYGAIN_EXECUTABLE",
|
||||
"foobar",
|
||||
|
@ -24,11 +24,11 @@ def test_analyze_missing_replaygain():
|
|||
analyze_replaygain(str(FILES[0].path), dict())
|
||||
|
||||
|
||||
def test_analyze_invalid_filepath():
|
||||
def test_analyze_replaygain_invalid_filepath():
|
||||
with pytest.raises(KeyError):
|
||||
test_analyze("non-existent-file", None)
|
||||
test_analyze_replaygain("non-existent-file", None)
|
||||
|
||||
|
||||
def test_analyze_invalid_wma():
|
||||
with pytest.raises(KeyError):
|
||||
test_analyze(FILE_INVALID_DRM, None)
|
||||
test_analyze_replaygain(FILE_INVALID_DRM, None)
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import os
|
||||
import shutil
|
||||
import tempfile
|
||||
import time
|
||||
from unittest import mock
|
||||
|
||||
|
@ -20,7 +19,7 @@ from ..conftest import AUDIO_FILENAME
|
|||
(("", "", "", 12345), TypeError),
|
||||
],
|
||||
)
|
||||
def test_move_wrong_params(params, exception):
|
||||
def test_organise_file_wrong_params(params, exception):
|
||||
with pytest.raises(exception):
|
||||
organise_file(*params)
|
||||
|
||||
|
@ -67,7 +66,7 @@ def import_and_restore(src_dir, dest_dir) -> dict:
|
|||
return metadata
|
||||
|
||||
|
||||
def test_move_duplicate_file(src_dir, dest_dir):
|
||||
def test_organise_file_duplicate_file(src_dir, dest_dir):
|
||||
# Import the file once
|
||||
import_and_restore(src_dir, dest_dir)
|
||||
|
||||
|
@ -79,7 +78,7 @@ def test_move_duplicate_file(src_dir, dest_dir):
|
|||
assert os.path.exists(os.path.join(dest_dir, AUDIO_FILENAME))
|
||||
|
||||
|
||||
def test_move_triplicate_file(src_dir, dest_dir):
|
||||
def test_organise_file_triplicate_file(src_dir, dest_dir):
|
||||
# Here we use mock to patch out the time.localtime() function so that it
|
||||
# always returns the same value. This allows us to consistently simulate this test cases
|
||||
# where the last two of the three files are imported at the same time as the timestamp.
|
||||
|
@ -105,7 +104,7 @@ def test_move_triplicate_file(src_dir, dest_dir):
|
|||
assert len(os.path.basename(metadata2["full_path"]).split("_")) == 3
|
||||
|
||||
|
||||
def test_move_bad_permissions_dest_dir(src_dir):
|
||||
def test_organise_file_bad_permissions_dest_dir(src_dir):
|
||||
with pytest.raises(OSError):
|
||||
# /sys is using sysfs on Linux, which is unwritable
|
||||
organise_file(
|
||||
|
|
Loading…
Reference in New Issue