mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-10-26 19:01:39 -04:00
Tags can be created and deleted in UI. Adding tag_file using id to avoid session error. Using UTC in test. Matching tag_names style in test. Tag icon is displayed on file rows. Archives, Videos and Files can be filtered by their tags. Tags can be added and removed from UI. Tags are displayed in VideoPlayer. The tags of a file are returned in it's JSON. Video favorites are converted to Favorite tag on channel config import. Updating tests to match frontend usage. PDF creator and modification time are displayed. Reworking file search to use Video.__json__ for complex video relations. Archives can be viewed. Removing ebook.title. Reworking alembic migration to be an upgrade rather than a replace. Skipping test on circleci. Clearing out video caption index only if extract_subtitles if off. Channel tests pass. Some video tests pass. Missing videos can be found. A video can be downloaded. Orphaned files can be found. Videos can be tagged. Videos can be searched. Videos can be modeled. Converting some tests to use FileGroup.primary_path. Adding archive and domains to alembic migration. Testing cascading Archive titles. Archives now uses FileGroup. archive.lib tests pass. Archive is partially converted to FileGroup. Calculating FileGroup.primary file on refresh, rather than on select. wrolpi tests pass. Using FilesType to convert between str/pathlib.Path for FileGroup.files. Using list of files in FileGroup.files instead of dictionary. Storing files in dedicated FileGroup.files to avoid overwriting them. Adding comment explaining CASE. Not overwriting FileGroup.data on refresh if no change has been detected. Removing File model in favor of FileGroup.data. Adding typing to Files methods. Files are indexed using the primary mimetype of the FileGroup. files test_lib tests pass. Removing file_group_file in favor of simple one-to-many relationship. PDF files are indexed during refresh. Adding Tag and TagFile to tag files with specific tags. Only iterating when full_stem_ids has contents. Testing that FileGroups are related to their Files. Files and file_groups are created and linked. Bump webpack from 5.75.0 to 5.76.1 in /app (#160) Bumps [webpack](https://github.com/webpack/webpack) from 5.75.0 to 5.76.1. - [Release notes](https://github.com/webpack/webpack/releases) - [Commits](https://github.com/webpack/webpack/compare/v5.75.0...v5.76.1) --- updated-dependencies: - dependency-name: webpack dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
73 lines
2.9 KiB
Python
73 lines
2.9 KiB
Python
import pytest
|
|
|
|
from modules.videos.models import Video
|
|
from wrolpi.dates import now
|
|
from wrolpi.files import lib as files_lib
|
|
from wrolpi.files.models import FileGroup
|
|
|
|
|
|
def test_delete_video_no_channel(test_session, simple_video):
|
|
"""A Video can be deleted even if it does not have a channel."""
|
|
assert simple_video.channel
|
|
simple_video.channel_id = None
|
|
test_session.commit()
|
|
|
|
paths = list(simple_video.file_group.my_paths())
|
|
|
|
assert not simple_video.channel
|
|
simple_video.delete()
|
|
|
|
# All files were deleted.
|
|
for path in paths:
|
|
assert not path.exists()
|
|
|
|
test_session.commit()
|
|
|
|
assert test_session.query(FileGroup).count() == 0
|
|
assert test_session.query(Video).count() == 0
|
|
|
|
|
|
def test_delete_video(test_session, video_factory):
|
|
"""When a Video record is deleted, all referenced file records should be deleted."""
|
|
video = video_factory(with_video_file=True, with_poster_ext='png')
|
|
test_session.commit()
|
|
|
|
assert video.video_path.is_file(), 'Video file was not created.'
|
|
assert video.poster_path.is_file(), 'Video poster was not created.'
|
|
assert test_session.query(Video).count() == 1, 'Video was not created.'
|
|
assert test_session.query(FileGroup).count() == 1, 'Video file and poster file were not created.'
|
|
|
|
video.delete()
|
|
test_session.commit()
|
|
assert test_session.query(Video).count() == 0, 'Video was not deleted.'
|
|
assert test_session.query(FileGroup).count() == 0, 'Video files were not deleted.'
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_video_channel_refresh(test_session, test_directory, channel_factory, video_factory):
|
|
"""A Video will be associated with a Channel when it's files are in that Channel's directory."""
|
|
# Create a video file in this channel's directory.
|
|
channel = channel_factory()
|
|
video1_path = channel.directory / 'video1.mp4'
|
|
video_factory(channel_id=channel.id, with_video_file=video1_path, with_poster_ext='jpg')
|
|
# Create another video outside the channel's directory. It should not have a channel.
|
|
video2_path = test_directory / 'video2.mp4'
|
|
video_factory(with_video_file=video2_path)
|
|
# Delete all FileGroups so the channel will be associated again.
|
|
test_session.query(FileGroup).delete()
|
|
test_session.commit()
|
|
|
|
await files_lib.refresh_files()
|
|
|
|
assert test_session.query(FileGroup).count() == 2
|
|
assert test_session.query(Video).count() == 2
|
|
|
|
# The video is associated with `simple_channel` because its file is in the Channel's directory.
|
|
video1: Video = Video.find_by_path(video1_path, test_session)
|
|
video2: Video = Video.find_by_path(video2_path, test_session)
|
|
assert video1.channel == channel
|
|
assert not video2.channel
|
|
assert video1.__json__()['video']['channel']
|
|
video_channel = video1.__json__()['video']['channel']
|
|
assert video_channel['id'] == channel.id
|
|
assert video_channel['name'] == channel.name
|