sintonia/python_apps/airtime_analyzer/tests/cuepoint_analyzer_test.py

39 lines
1.1 KiB
Python
Raw Normal View History

import pytest
from airtime_analyzer.cuepoint_analyzer import CuePointAnalyzer
2021-08-30 21:23:48 +02:00
from .fixtures import FILE_INVALID_DRM, FILES, Fixture
2021-05-27 16:23:02 +02:00
@pytest.mark.parametrize(
2021-08-30 21:23:48 +02:00
"filepath,length,cuein,cueout",
map(lambda i: (str(i.path), i.length, i.cuein, i.cueout), FILES),
)
2021-08-30 21:23:48 +02:00
def test_analyze(filepath, length, cuein, cueout):
metadata = CuePointAnalyzer.analyze(filepath, dict())
2021-08-30 21:23:48 +02:00
assert metadata["length_seconds"] == pytest.approx(length, abs=0.1)
# Silan does not work with m4a files yet
if filepath.endswith("m4a"):
return
assert float(metadata["cuein"]) == pytest.approx(cuein, abs=0.5)
assert float(metadata["cueout"]) == pytest.approx(cueout, abs=0.5)
2021-05-27 16:23:02 +02:00
2021-05-29 18:39:10 +02:00
def test_analyze_missing_silan():
old = CuePointAnalyzer.SILAN_EXECUTABLE
CuePointAnalyzer.SILAN_EXECUTABLE = "foobar"
2021-08-30 21:23:48 +02:00
CuePointAnalyzer.analyze(str(FILES[0].path), dict())
CuePointAnalyzer.SILAN_EXECUTABLE = old
2021-05-27 16:23:02 +02:00
2021-05-29 18:39:10 +02:00
def test_analyze_invalid_filepath():
with pytest.raises(KeyError):
2021-08-30 21:23:48 +02:00
test_analyze("non-existent-file", None, None, None)
2021-05-27 16:23:02 +02:00
2021-05-29 18:39:10 +02:00
def test_analyze_invalid_wma():
with pytest.raises(KeyError):
2021-08-30 21:23:48 +02:00
test_analyze(FILE_INVALID_DRM, None, None, None)