2021-06-04 14:03:41 +02:00
|
|
|
import pytest
|
2014-12-11 00:44:35 +01:00
|
|
|
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
|
|
|
|
2021-06-04 14:03:41 +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-06-04 14:03:41 +02:00
|
|
|
)
|
2021-08-30 21:23:48 +02:00
|
|
|
def test_analyze(filepath, length, cuein, cueout):
|
2021-06-04 14:03:41 +02:00
|
|
|
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
|
|
|
|
2014-12-11 00:44:35 +01:00
|
|
|
|
2021-05-29 18:39:10 +02:00
|
|
|
def test_analyze_missing_silan():
|
2021-06-04 14:03:41 +02:00
|
|
|
old = CuePointAnalyzer.SILAN_EXECUTABLE
|
|
|
|
CuePointAnalyzer.SILAN_EXECUTABLE = "foobar"
|
2021-08-30 21:23:48 +02:00
|
|
|
CuePointAnalyzer.analyze(str(FILES[0].path), dict())
|
2021-06-04 14:03:41 +02:00
|
|
|
CuePointAnalyzer.SILAN_EXECUTABLE = old
|
2021-05-27 16:23:02 +02:00
|
|
|
|
2014-12-11 00:44:35 +01:00
|
|
|
|
2021-05-29 18:39:10 +02:00
|
|
|
def test_analyze_invalid_filepath():
|
2021-06-04 14:03:41 +02:00
|
|
|
with pytest.raises(KeyError):
|
2021-08-30 21:23:48 +02:00
|
|
|
test_analyze("non-existent-file", None, None, None)
|
2014-12-11 00:44:35 +01:00
|
|
|
|
2021-05-27 16:23:02 +02:00
|
|
|
|
2021-05-29 18:39:10 +02:00
|
|
|
def test_analyze_invalid_wma():
|
2021-06-04 14:03:41 +02:00
|
|
|
with pytest.raises(KeyError):
|
2021-08-30 21:23:48 +02:00
|
|
|
test_analyze(FILE_INVALID_DRM, None, None, None)
|