2024-03-10 11:45:24 -07:00
|
|
|
from unittest.mock import MagicMock
|
|
|
|
|
|
|
|
import ffmpeg
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
from croaker import playlist
|
|
|
|
from croaker import transcoder
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('suffix, expected', [
|
2024-03-17 15:15:41 -07:00
|
|
|
('.mp3', b'_theme.mp3\n'),
|
2024-03-10 11:45:24 -07:00
|
|
|
('.foo', b'transcoding!\n'),
|
|
|
|
])
|
|
|
|
def test_transcoder_open(monkeypatch, suffix, expected):
|
|
|
|
monkeypatch.setattr(transcoder, 'ffmpeg', MagicMock(spec=ffmpeg, **{
|
|
|
|
'input.return_value.'
|
|
|
|
'output.return_value.'
|
|
|
|
'global_args.return_value.'
|
|
|
|
'compile.return_value': ['echo', 'transcoding!'],
|
|
|
|
}))
|
|
|
|
|
|
|
|
pl = playlist.Playlist(name='test_playlist')
|
|
|
|
track = [t for t in pl.tracks if t.suffix == suffix][0]
|
|
|
|
with transcoder.open(track) as handle:
|
|
|
|
assert handle.read() == expected
|