mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-19 14:36:22 -05:00
41 lines
1.8 KiB
Python
41 lines
1.8 KiB
Python
import pathlib
|
|
|
|
import pytest
|
|
|
|
from modules.videos.models import Video, Channel
|
|
from wrolpi.common import get_relative_to_media_directory, get_wrolpi_config
|
|
|
|
|
|
@pytest.mark.asyncio()
|
|
async def test_ffprobe_stream_methods(simple_video):
|
|
"""ffprobe data can be used to get data about specific streams in the video file."""
|
|
assert await simple_video.get_ffprobe_json()
|
|
|
|
assert simple_video.get_streams_by_codec_type('video')
|
|
assert simple_video.get_streams_by_codec_type('audio')
|
|
assert simple_video.get_streams_by_codec_type('subtitle')
|
|
|
|
assert simple_video.get_streams_by_codec_name('h264')
|
|
assert simple_video.get_streams_by_codec_name('aac')
|
|
assert simple_video.get_streams_by_codec_name('mov_text')
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_channel_move(test_async_client, test_session, test_directory, channel_factory, video_factory):
|
|
"""A Channel can be moved to another directory, any files in the Channel's directory are moved."""
|
|
channel = channel_factory(name='Channel Name')
|
|
video = video_factory(title='Vid', channel_id=channel.id)
|
|
test_session.commit()
|
|
assert video.channel_id == channel.id
|
|
assert str(get_relative_to_media_directory(video.video_path)) == 'videos/Channel Name/Vid.mp4'
|
|
|
|
foo = test_directory / 'foo/New Channel Directory'
|
|
foo.mkdir(parents=True)
|
|
await channel.move(foo, test_session)
|
|
assert channel.directory == foo
|
|
assert channel.directory != (test_directory / 'New Channel Directory')
|
|
video = test_session.query(Video).one()
|
|
assert str(get_relative_to_media_directory(video.video_path)) == 'foo/New Channel Directory/Vid.mp4'
|
|
assert str(video.video_path).startswith(str(channel.directory))
|
|
# Old directory is deleted.
|
|
assert not (test_directory / 'Channel Name').exists()
|