2022-01-21 09:07:27 +01:00
|
|
|
import distro
|
2021-06-04 14:04:07 +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_replaygain import analyze_replaygain
|
2014-12-11 20:12:41 +01:00
|
|
|
|
2022-01-21 09:07:27 +01:00
|
|
|
from ..fixtures import FILES
|
2021-08-30 21:23:48 +02:00
|
|
|
|
2017-02-28 14:07:34 +01:00
|
|
|
|
2021-06-04 14:04:07 +02:00
|
|
|
@pytest.mark.parametrize(
|
2021-08-30 21:23:48 +02:00
|
|
|
"filepath,replaygain",
|
2022-01-21 09:07:27 +01:00
|
|
|
map(lambda i: pytest.param(str(i.path), i.replaygain, id=i.path.name), FILES),
|
2021-06-04 14:04:07 +02:00
|
|
|
)
|
2022-01-21 05:41:51 +01:00
|
|
|
def test_analyze_replaygain(filepath, replaygain):
|
2022-01-21 09:07:27 +01:00
|
|
|
tolerance = 0.8
|
2021-05-27 16:23:02 +02:00
|
|
|
|
2022-01-21 09:07:27 +01:00
|
|
|
# On bionic, replaygain is a bit higher for loud mp3 files.
|
|
|
|
# This huge tolerance makes the test pass, with values devianting from ~-17 to ~-13
|
|
|
|
if distro.codename() == "bionic" and str(filepath).endswith("+12.mp3"):
|
|
|
|
tolerance = 5
|
2014-12-11 20:12:41 +01:00
|
|
|
|
2022-01-21 09:07:27 +01:00
|
|
|
metadata = analyze_replaygain(filepath, dict())
|
|
|
|
assert metadata["replay_gain"] == pytest.approx(replaygain, abs=tolerance)
|