mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-05 03:49:24 +02:00
Blacked the code
This commit is contained in:
parent
b6fc0051fa
commit
62ca3bd736
279 changed files with 8861 additions and 9527 deletions
|
@ -7,35 +7,31 @@ DATA_DIR = os.path.dirname(os.path.abspath(__file__))
|
|||
|
||||
|
||||
def test_guess_mimetype_try_using_extension(factories, mocker):
|
||||
mocker.patch(
|
||||
'magic.from_buffer', return_value='audio/mpeg')
|
||||
f = factories['music.TrackFile'].build(
|
||||
audio_file__filename='test.ogg')
|
||||
mocker.patch("magic.from_buffer", return_value="audio/mpeg")
|
||||
f = factories["music.TrackFile"].build(audio_file__filename="test.ogg")
|
||||
|
||||
assert utils.guess_mimetype(f.audio_file) == 'audio/mpeg'
|
||||
assert utils.guess_mimetype(f.audio_file) == "audio/mpeg"
|
||||
|
||||
|
||||
@pytest.mark.parametrize('wrong', [
|
||||
'application/octet-stream',
|
||||
'application/x-empty',
|
||||
])
|
||||
@pytest.mark.parametrize("wrong", ["application/octet-stream", "application/x-empty"])
|
||||
def test_guess_mimetype_try_using_extension_if_fail(wrong, factories, mocker):
|
||||
mocker.patch(
|
||||
'magic.from_buffer', return_value=wrong)
|
||||
f = factories['music.TrackFile'].build(
|
||||
audio_file__filename='test.mp3')
|
||||
mocker.patch("magic.from_buffer", return_value=wrong)
|
||||
f = factories["music.TrackFile"].build(audio_file__filename="test.mp3")
|
||||
|
||||
assert utils.guess_mimetype(f.audio_file) == 'audio/mpeg'
|
||||
assert utils.guess_mimetype(f.audio_file) == "audio/mpeg"
|
||||
|
||||
|
||||
@pytest.mark.parametrize('name, expected', [
|
||||
('sample.flac', {'bitrate': 1608000, 'length': 0.001}),
|
||||
('test.mp3', {'bitrate': 8000, 'length': 267.70285714285717}),
|
||||
('test.ogg', {'bitrate': 128000, 'length': 229.18304166666667}),
|
||||
])
|
||||
@pytest.mark.parametrize(
|
||||
"name, expected",
|
||||
[
|
||||
("sample.flac", {"bitrate": 1608000, "length": 0.001}),
|
||||
("test.mp3", {"bitrate": 8000, "length": 267.70285714285717}),
|
||||
("test.ogg", {"bitrate": 128000, "length": 229.18304166666667}),
|
||||
],
|
||||
)
|
||||
def test_get_audio_file_data(name, expected):
|
||||
path = os.path.join(DATA_DIR, name)
|
||||
with open(path, 'rb') as f:
|
||||
with open(path, "rb") as f:
|
||||
result = utils.get_audio_file_data(f)
|
||||
|
||||
assert result == expected
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue