mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-12-02 12:56:24 -05:00
Preserving FileGroup.title when moving.
This commit is contained in:
parent
2a83517d93
commit
d8ef7e175e
5 changed files with 23 additions and 9 deletions
|
|
@ -1,9 +1,7 @@
|
|||
import pathlib
|
||||
|
||||
import pytest
|
||||
|
||||
from modules.videos.models import Video, Channel
|
||||
from wrolpi.common import get_relative_to_media_directory, get_wrolpi_config
|
||||
from modules.videos.models import Video
|
||||
from wrolpi.common import get_relative_to_media_directory
|
||||
|
||||
|
||||
@pytest.mark.asyncio()
|
||||
|
|
@ -25,13 +23,19 @@ async def test_channel_move(test_async_client, test_session, test_directory, cha
|
|||
"""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)
|
||||
extra_file = (channel.directory / 'extra.txt')
|
||||
extra_file.write_text('extra stuff')
|
||||
test_session.commit()
|
||||
assert video.channel_id == channel.id
|
||||
assert str(get_relative_to_media_directory(video.video_path)) == 'videos/Channel Name/Vid.mp4'
|
||||
|
||||
# Destination must already exist.
|
||||
foo = test_directory / 'foo/New Channel Directory'
|
||||
foo.mkdir(parents=True)
|
||||
|
||||
# Move the Channel.
|
||||
await channel.move(foo, test_session)
|
||||
|
||||
assert channel.directory == foo
|
||||
assert channel.directory != (test_directory / 'New Channel Directory')
|
||||
video = test_session.query(Video).one()
|
||||
|
|
@ -39,3 +43,7 @@ async def test_channel_move(test_async_client, test_session, test_directory, cha
|
|||
assert str(video.video_path).startswith(str(channel.directory))
|
||||
# Old directory is deleted.
|
||||
assert not (test_directory / 'Channel Name').exists()
|
||||
# Extra file was moved.
|
||||
assert not extra_file.is_file()
|
||||
assert (test_directory / 'foo/New Channel Directory/extra.txt').is_file()
|
||||
assert (test_directory / 'foo/New Channel Directory/extra.txt').read_text() == 'extra stuff'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue