rolling recent dry-run test

This commit is contained in:
jbannon 2022-07-06 04:44:58 +00:00
parent af03afc8f3
commit 74788d4c41
3 changed files with 52 additions and 9 deletions

View file

@ -143,6 +143,10 @@ class FileHandlerTransactionLog:
lines.extend([_indent_metadata_line(line) for line in file_metadata.metadata])
if self.files_removed:
# Add a blank line to separate created/removed files
if self.files_created:
lines.append("")
removed_line = f"Files removed from '{output_directory}'"
removed_line_dash = "-" * 40
lines.extend([removed_line, removed_line_dash])

View file

@ -0,0 +1,15 @@
Files created in '{output_directory}'
----------------------------------------
.ytdl-sub-pz-download-archive.json
fanart.jpg
poster.jpg
tvshow.nfo
NFO tags:
tvshow:
title: Project / Zombie
Files removed from '{output_directory}'
----------------------------------------
Season 2018/s2018.e1029 - Jesse's Minecraft Server _ Teaser Trailer-thumb.jpg
Season 2018/s2018.e1029 - Jesse's Minecraft Server _ Teaser Trailer.mp4
Season 2018/s2018.e1029 - Jesse's Minecraft Server _ Teaser Trailer.nfo

View file

@ -361,6 +361,7 @@ class TestChannelAsKodiTvShow:
relative_directory=output_directory
)
@pytest.mark.parametrize("dry_run", [True, False])
def test_rolling_recent_channel_download(
self,
recent_channel_subscription,
@ -368,14 +369,22 @@ class TestChannelAsKodiTvShow:
expected_recent_channel_download,
expected_rolling_recent_channel_download,
output_directory,
dry_run,
):
# First, download recent vids
# First, download recent vids. Always download since we want to test dry-run
# on the rolling recent portion.
with assert_debug_log(
logger=ytdl_sub.downloaders.downloader.logger,
expected_message="RejectedVideoReached, stopping additional downloads",
):
recent_channel_subscription.download()
expected_recent_channel_download.assert_files_exist(relative_directory=output_directory)
transaction_log = recent_channel_subscription.download()
expected_recent_channel_download.assert_files_exist(relative_directory=output_directory)
assert_transaction_log_matches(
output_directory=output_directory,
transaction_log=transaction_log,
transaction_log_summary_file_name="youtube/test_channel_recent.txt",
)
# Then, download the rolling recent vids subscription. This should remove one of the
# two videos
@ -383,18 +392,33 @@ class TestChannelAsKodiTvShow:
logger=ytdl_sub.downloaders.downloader.logger,
expected_message="ExistingVideoReached, stopping additional downloads",
):
rolling_recent_channel_subscription.download()
transaction_log = rolling_recent_channel_subscription.download(dry_run=dry_run)
assert_transaction_log_matches(
output_directory=output_directory,
transaction_log=transaction_log,
transaction_log_summary_file_name="youtube/test_channel_rolling_recent.txt",
regenerate_transaction_log=True,
)
if not dry_run:
expected_rolling_recent_channel_download.assert_files_exist(
relative_directory=output_directory
)
# Invoke the rolling download again, ensure downloading stopped early from it already
# existing
with assert_debug_log(
logger=ytdl_sub.downloaders.downloader.logger,
expected_message="ExistingVideoReached, stopping additional downloads",
):
rolling_recent_channel_subscription.download()
if not dry_run:
with assert_debug_log(
logger=ytdl_sub.downloaders.downloader.logger,
expected_message="ExistingVideoReached, stopping additional downloads",
):
transaction_log = rolling_recent_channel_subscription.download()
assert_transaction_log_matches(
output_directory=output_directory,
transaction_log=transaction_log,
transaction_log_summary_file_name="youtube/test_channel_no_additional_downloads.txt",
)
expected_rolling_recent_channel_download.assert_files_exist(
relative_directory=output_directory
)