better test

This commit is contained in:
Jesse Bannon 2023-07-28 12:39:27 -07:00
parent 07b5b28215
commit 915e37d44c

View file

@ -10,6 +10,7 @@ from ytdl_sub.downloaders.ytdlp import YTDLP
from ytdl_sub.entries.entry import Entry from ytdl_sub.entries.entry import Entry
from ytdl_sub.subscriptions.subscription import Subscription from ytdl_sub.subscriptions.subscription import Subscription
from ytdl_sub.utils.file_handler import FileHandler from ytdl_sub.utils.file_handler import FileHandler
from ytdl_sub.utils.thumbnail import try_convert_download_thumbnail
@pytest.fixture @pytest.fixture
@ -158,17 +159,17 @@ class TestYoutubeVideo:
preset_dict=single_video_preset_dict, preset_dict=single_video_preset_dict,
) )
def delete_entry_thumb(entry: Entry) -> None: def delete_entry_thumbnail(entry: Entry) -> None:
if ytdlp_thumb_path := entry.try_get_ytdlp_download_thumbnail_path():
FileHandler.delete(ytdlp_thumb_path)
FileHandler.delete(entry.get_download_thumbnail_path()) FileHandler.delete(entry.get_download_thumbnail_path())
try_convert_download_thumbnail(entry=entry)
# Pretend the thumbnail did not download via returning nothing for its downloaded path # Pretend the thumbnail did not download via returning nothing for its downloaded path
with patch.object(YTDLP, "_EXTRACT_ENTRY_NUM_RETRIES", 1), patch.object( with patch.object(YTDLP, "_EXTRACT_ENTRY_NUM_RETRIES", 1), patch(
Entry, "get_ytdlp_download_thumbnail_path"
) as mock_ytdlp_path, patch(
"ytdl_sub.downloaders.url.downloader.try_convert_download_thumbnail", "ytdl_sub.downloaders.url.downloader.try_convert_download_thumbnail",
side_effect=delete_entry_thumb, side_effect=delete_entry_thumbnail,
): ):
mock_ytdlp_path.return_value = None
transaction_log = single_video_subscription.download(dry_run=False) transaction_log = single_video_subscription.download(dry_run=False)
assert_transaction_log_matches( assert_transaction_log_matches(