2022-01-17 20:31:43 +01:00
|
|
|
from unittest.mock import patch
|
|
|
|
|
2021-09-01 21:34:00 +02:00
|
|
|
import distro
|
2021-06-04 14:04:32 +02:00
|
|
|
import pytest
|
2021-10-17 16:24:37 +02:00
|
|
|
|
2022-01-28 06:09:19 +01:00
|
|
|
from libretime_analyzer.pipeline.analyze_playability import (
|
2021-06-04 14:04:32 +02:00
|
|
|
UnplayableFileError,
|
2022-01-17 20:31:43 +01:00
|
|
|
analyze_playability,
|
2021-06-04 14:04:32 +02:00
|
|
|
)
|
|
|
|
|
2022-01-21 05:41:51 +01:00
|
|
|
from ..fixtures import FILE_INVALID_DRM, FILES
|
2021-08-30 21:23:48 +02:00
|
|
|
|
2021-06-04 14:04:32 +02:00
|
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
|
|
"filepath",
|
2021-08-30 21:23:48 +02:00
|
|
|
map(lambda i: str(i.path), FILES),
|
2021-06-04 14:04:32 +02:00
|
|
|
)
|
2022-01-21 05:41:51 +01:00
|
|
|
def test_analyze_playability(filepath):
|
2022-08-09 20:49:04 +02:00
|
|
|
analyze_playability(filepath, {})
|
2014-12-11 21:45:45 +01:00
|
|
|
|
2021-05-27 16:23:02 +02:00
|
|
|
|
2022-01-21 05:41:51 +01:00
|
|
|
def test_analyze_playability_missing_liquidsoap():
|
2022-01-17 20:31:43 +01:00
|
|
|
with patch(
|
2022-08-09 15:54:58 +02:00
|
|
|
"libretime_analyzer.pipeline._liquidsoap.LIQUIDSOAP",
|
2022-01-17 20:31:43 +01:00
|
|
|
"foobar",
|
|
|
|
):
|
2022-08-09 20:49:04 +02:00
|
|
|
analyze_playability(str(FILES[0].path), {})
|
2021-05-27 16:23:02 +02:00
|
|
|
|
2014-12-11 21:45:45 +01:00
|
|
|
|
2022-01-21 05:41:51 +01:00
|
|
|
def test_analyze_playability_invalid_filepath():
|
2021-06-04 14:04:32 +02:00
|
|
|
with pytest.raises(UnplayableFileError):
|
2022-01-21 05:41:51 +01:00
|
|
|
test_analyze_playability("non-existent-file")
|
2014-12-11 21:45:45 +01:00
|
|
|
|
2021-05-27 16:23:02 +02:00
|
|
|
|
2022-01-21 05:41:51 +01:00
|
|
|
def test_analyze_playability_invalid_wma():
|
2022-09-09 20:45:59 +02:00
|
|
|
# Liquisoap does not fail with wma files on focal, bullseye, jammy
|
|
|
|
if distro.codename() in ("focal", "bullseye", "jammy"):
|
2021-09-01 21:34:00 +02:00
|
|
|
return
|
|
|
|
|
2021-06-04 14:29:41 +02:00
|
|
|
with pytest.raises(UnplayableFileError):
|
2022-01-21 05:41:51 +01:00
|
|
|
test_analyze_playability(FILE_INVALID_DRM)
|
2014-12-11 21:45:45 +01:00
|
|
|
|
2021-05-27 16:23:02 +02:00
|
|
|
|
2022-01-21 05:41:51 +01:00
|
|
|
def test_analyze_playability_unknown():
|
2021-06-04 14:04:32 +02:00
|
|
|
with pytest.raises(UnplayableFileError):
|
2022-01-21 05:41:51 +01:00
|
|
|
test_analyze_playability("https://www.google.com")
|