diff --git a/modules/archive/test/test_lib.py b/modules/archive/test/test_lib.py index 69b37b83..f54194da 100644 --- a/modules/archive/test/test_lib.py +++ b/modules/archive/test/test_lib.py @@ -663,3 +663,9 @@ async def test_archive_download_index(test_session, test_directory, image_file): assert archive.title == 'the singlefile', 'Did not get the title from the singlefile' assert archive.screenshot_path and archive.screenshot_file and archive.screenshot_path.is_file(), \ 'Did not store the screenshot' + + assert not archive.singlefile_file.associated + assert archive.readability_txt_file.associated \ + and archive.readability_json_file.associated \ + and archive.readability_file.associated \ + and archive.screenshot_file.associated, 'Archive files must be associated' diff --git a/modules/videos/models.py b/modules/videos/models.py index 52dde7f7..97d73c5b 100644 --- a/modules/videos/models.py +++ b/modules/videos/models.py @@ -289,10 +289,13 @@ class Video(ModelHelper, Base): if poster_file: poster_file.do_index() + poster_file.associated = True if caption_file: caption_file.do_index() + caption_file.associated = True if info_json_file: info_json_file.do_index() + info_json_file.associated = True session.flush([i for i in files]) diff --git a/modules/videos/test/test_downloader.py b/modules/videos/test/test_downloader.py index 2cc409a7..e8bf6b8c 100644 --- a/modules/videos/test/test_downloader.py +++ b/modules/videos/test/test_downloader.py @@ -413,12 +413,13 @@ async def test_video_download_1(test_session, test_directory, simple_channel, vi @pytest.mark.asyncio async def test_download_result(test_session, test_directory, video_download_manager, mock_video_process_runner, - mock_video_extract_info): + mock_video_extract_info, image_file): """VideoDownloader returns a DownloadResult when complete.""" channel_directory = test_directory / 'videos/channel name' channel_directory.mkdir(parents=True) video_file = channel_directory / 'the video.mp4' shutil.copy(PROJECT_DIR / 'test/big_buck_bunny_720p_1mb.mp4', video_file) + image_file.rename(video_file.with_suffix('.jpg')) mock_video_extract_info.return_value = example_video_json with mock.patch('modules.videos.downloader.VideoDownloader.prepare_filename') as mock_prepare_filename: @@ -430,6 +431,12 @@ async def test_download_result(test_session, test_directory, video_download_mana assert download.url == 'https://example.com' assert download.location == '/videos/channel/1/video/1' + # Video files are associated. + video = test_session.query(Video).one() + assert not video.video_file.associated, 'Video file should not be associated.' + assert video.poster_path.is_file(), 'Poster file was not found.' + assert video.poster_file.associated, 'Poster file was not associated.' + example_playlist_json = { '_type': 'playlist',