From d726a097b02ebbb09003df4b6f1cd5837d575282 Mon Sep 17 00:00:00 2001 From: jo Date: Mon, 10 Oct 2022 12:17:39 +0200 Subject: [PATCH] test(analyzer): fix wrong bit_rate values Mutagen >=1.46 properly compute the bit_rate for wav files. --- analyzer/tests/fixtures/__init__.py | 8 ++++---- analyzer/tests/pipeline/analyze_metadata_test.py | 7 +++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/analyzer/tests/fixtures/__init__.py b/analyzer/tests/fixtures/__init__.py index 32560c83f..b6265a371 100644 --- a/analyzer/tests/fixtures/__init__.py +++ b/analyzer/tests/fixtures/__init__.py @@ -201,7 +201,7 @@ FILES_TAGGED = [ here / "s1-mono-tagged.wav", { **meta, - "bit_rate": approx(96000, abs=1e2), + "bit_rate": approx(768000, abs=1e2), "channels": 1, "mime": "audio/wav", }, @@ -210,7 +210,7 @@ FILES_TAGGED = [ here / "s1-stereo-tagged.wav", { **meta, - "bit_rate": approx(384000, abs=1e2), + "bit_rate": approx(1536000, abs=1e2), "channels": 2, "mime": "audio/wav", }, @@ -333,7 +333,7 @@ FILES_TAGGED += [ here / "s1-mono-tagged-utf8.wav", { **meta, - "bit_rate": approx(96000, abs=1e2), + "bit_rate": approx(768000, abs=1e2), "channels": 1, "mime": "audio/wav", }, @@ -342,7 +342,7 @@ FILES_TAGGED += [ here / "s1-stereo-tagged-utf8.wav", { **meta, - "bit_rate": approx(384000, abs=1e2), + "bit_rate": approx(1536000, abs=1e2), "channels": 2, "mime": "audio/wav", }, diff --git a/analyzer/tests/pipeline/analyze_metadata_test.py b/analyzer/tests/pipeline/analyze_metadata_test.py index f0598d672..35827bad7 100644 --- a/analyzer/tests/pipeline/analyze_metadata_test.py +++ b/analyzer/tests/pipeline/analyze_metadata_test.py @@ -1,5 +1,6 @@ from pathlib import Path +import distro import pytest from libretime_analyzer.pipeline.analyze_metadata import analyze_metadata @@ -27,6 +28,12 @@ def test_analyze_metadata(filepath: Path, metadata: dict): del metadata["length"] del found["length"] + # Mutagen <1.46 computes a wrong bit_rate for wav files, this version + # of mutagen is only installed on bionic (python <3.7) + if filepath.suffix == ".wav" and distro.codename() == "bionic": + del metadata["bit_rate"] + del found["bit_rate"] + # mp3,ogg,flac files does not support comments yet if not filepath.suffix == ".m4a": if "comment" in metadata: