libretime/analyzer/tests/pipeline/analyze_playability_test.py

47 lines
1.2 KiB
Python
Raw Permalink Normal View History

from unittest.mock import patch
import distro
import pytest
from libretime_analyzer.pipeline.analyze_playability import (
UnplayableFileError,
analyze_playability,
)
from ..fixtures import FILE_INVALID_DRM, FILES
2021-08-30 21:23:48 +02:00
@pytest.mark.parametrize(
"filepath",
2021-08-30 21:23:48 +02:00
map(lambda i: str(i.path), FILES),
)
def test_analyze_playability(filepath):
analyze_playability(filepath, {})
2021-05-27 16:23:02 +02:00
def test_analyze_playability_missing_liquidsoap():
with patch(
"libretime_analyzer.pipeline._liquidsoap.LIQUIDSOAP",
"foobar",
):
analyze_playability(str(FILES[0].path), {})
2021-05-27 16:23:02 +02:00
def test_analyze_playability_invalid_filepath():
with pytest.raises(UnplayableFileError):
test_analyze_playability("non-existent-file")
2021-05-27 16:23:02 +02:00
def test_analyze_playability_invalid_wma():
# Liquisoap does not fail with wma files on focal, bullseye, jammy
if distro.codename() in ("focal", "bullseye", "jammy"):
return
with pytest.raises(UnplayableFileError):
test_analyze_playability(FILE_INVALID_DRM)
2021-05-27 16:23:02 +02:00
def test_analyze_playability_unknown():
with pytest.raises(UnplayableFileError):
test_analyze_playability("https://www.google.com")