Commit c49b8eec authored by interfect's avatar interfect
Browse files

Test transcoding from Opus and other formats

parent 9ac829fa
Pipeline #13160 failed with stages
in 1 minute and 4 seconds
import os
import pathlib
import pytest
import tempfile
from funkwhale_api.music import utils
......@@ -28,6 +29,7 @@ def test_guess_mimetype_try_using_extension_if_fail(wrong, factories, mocker):
("sample.flac", {"bitrate": 1608000, "length": 0.001}),
("test.mp3", {"bitrate": 8000, "length": 267.70285714285717}),
("test.ogg", {"bitrate": 112000, "length": 1}),
("test.opus", {"bitrate": 112000, "length": 1})
],
)
def test_get_audio_file_data(name, expected):
......@@ -109,3 +111,21 @@ def test_get_dirs_and_files(path, expected, tmpdir):
(root_path / "System" / "file.ogg").touch()
assert utils.browse_dir(root_path, path) == expected
@pytest.mark.parametrize(
"name, expected",
[
("sample.flac", {"bitrate": 1608000, "length": 0.001}),
("test.mp3", {"bitrate": 8000, "length": 267.70285714285717}),
("test.ogg", {"bitrate": 112000, "length": 1}),
("test.opus", {"bitrate": 112000, "length": 1})
],
)
def test_transcode_file(name, expected):
path = pathlib.Path(os.path.join(DATA_DIR, name))
with tempfile.NamedTemporaryFile() as dest:
utils.transcode_file(path, pathlib.Path(dest.name))
with open(dest.name, "rb") as f:
result = utils.get_audio_file_data(f)
assert result == expected
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment