adding transcoder test coverage
This commit is contained in:
parent
d97faca0f7
commit
205177dca3
10
test/conftest.py
Normal file
10
test/conftest.py
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(autouse=True)
|
||||||
|
def mock_env(monkeypatch):
|
||||||
|
fixtures = Path(__file__).parent / 'fixtures'
|
||||||
|
monkeypatch.setenv('CROAKER_ROOT', str(fixtures))
|
||||||
|
monkeypatch.setenv('MEDIA_GLOB', '*.mp3,*.foo,*.bar')
|
|
@ -1,4 +1,3 @@
|
||||||
from pathlib import Path
|
|
||||||
from unittest.mock import MagicMock
|
from unittest.mock import MagicMock
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
@ -6,12 +5,6 @@ import pytest
|
||||||
import croaker.playlist
|
import croaker.playlist
|
||||||
import croaker.path
|
import croaker.path
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
|
||||||
def mock_env(monkeypatch):
|
|
||||||
fixtures = Path(__file__).parent / 'fixtures'
|
|
||||||
monkeypatch.setenv('CROAKER_ROOT', str(fixtures))
|
|
||||||
monkeypatch.setenv('MEDIA_GLOB', '*.mp3,*.foo,*.bar')
|
|
||||||
|
|
||||||
|
|
||||||
def test_playlist_loading():
|
def test_playlist_loading():
|
||||||
pl = croaker.playlist.Playlist(name='test_playlist')
|
pl = croaker.playlist.Playlist(name='test_playlist')
|
||||||
|
|
25
test/test_transcoder.py
Normal file
25
test/test_transcoder.py
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
from unittest.mock import MagicMock
|
||||||
|
|
||||||
|
import ffmpeg
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from croaker import playlist
|
||||||
|
from croaker import transcoder
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('suffix, expected', [
|
||||||
|
('.mp3', b''),
|
||||||
|
('.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
|
Loading…
Reference in New Issue
Block a user