diff --git a/tests/resources/transaction_log_summaries/plugins/nfo_tags/test_nfo.txt b/tests/resources/transaction_log_summaries/plugins/nfo_tags/test_nfo.txt index 7db40b0e..f375de19 100644 --- a/tests/resources/transaction_log_summaries/plugins/nfo_tags/test_nfo.txt +++ b/tests/resources/transaction_log_summaries/plugins/nfo_tags/test_nfo.txt @@ -1,7 +1,7 @@ Files created: ---------------------------------------- {output_directory} - .ytdl-sub-kodi_safe_xml-download-archive.json + .ytdl-sub-subscription_test-download-archive.json test.nfo NFO tags: kodi_safe_root 🎸: @@ -34,22 +34,22 @@ Files created: tag: the tag 🎸🎸 -{output_directory}/kodi_safe_xml - Can you hear the difference? 🎸🔥 #shorts.info.json - Can you hear the difference? 🎸🔥 #shorts.jpg - Can you hear the difference? 🎸🔥 #shorts.mp4 +{output_directory}/subscription_test + Mock Entry 20-1.info.json + Mock Entry 20-1.jpg + Mock Entry 20-1.mp4 Video Tags: album: Music Videos - artist: kodi_safe_xml + artist: subscription_test genre: ytdl-sub - premiered: 2022-06-30 - title: Can you hear the difference? 🎸🔥 #shorts - year: 2022 - Can you hear the difference? 🎸🔥 #shorts.nfo + premiered: 2020-08-08 + title: Mock Entry 20-1 + year: 2020 + Mock Entry 20-1.nfo NFO tags: musicvideo: album: Music Videos - artist: kodi_safe_xml + artist: subscription_test genre: ytdl-sub kodi_safe_multi_title 🎸: - value 1 🎸 @@ -80,5 +80,146 @@ Files created: tag: the tag 🎸🎸 - premiered: 2022-06-30 - title: Can you hear the difference? 🎸🔥 #shorts \ No newline at end of file + premiered: 2020-08-08 + title: Mock Entry 20-1 + Mock Entry 20-2.info.json + Mock Entry 20-2.jpg + Mock Entry 20-2.mp4 + Video Tags: + album: Music Videos + artist: subscription_test + genre: ytdl-sub + premiered: 2020-08-08 + title: Mock Entry 20-2 + year: 2020 + Mock Entry 20-2.nfo + NFO tags: + musicvideo: + album: Music Videos + artist: subscription_test + genre: ytdl-sub + kodi_safe_multi_title 🎸: + - value 1 🎸 + - value 2 🎸 + kodi_safe_multi_title_with_attrs: + - + attributes: + 🎸?: + value + newlines 🎸 + tag: + the + tag 1 🎸🎸 + - + attributes: + 🎸?: + value + newlines 🎸 + tag: + the + tag 2 🎸🎸 + kodi_safe_title 🎸: kodi_safe_value 🎸 + kodi_safe_title_with_attrs: + attributes: + 🎸?: + value + newlines 🎸 + tag: + the + tag 🎸🎸 + premiered: 2020-08-08 + title: Mock Entry 20-2 + Mock Entry 20-3.info.json + Mock Entry 20-3.jpg + Mock Entry 20-3.mp4 + Video Tags: + album: Music Videos + artist: subscription_test + genre: ytdl-sub + premiered: 2020-08-07 + title: Mock Entry 20-3 + year: 2020 + Mock Entry 20-3.nfo + NFO tags: + musicvideo: + album: Music Videos + artist: subscription_test + genre: ytdl-sub + kodi_safe_multi_title 🎸: + - value 1 🎸 + - value 2 🎸 + kodi_safe_multi_title_with_attrs: + - + attributes: + 🎸?: + value + newlines 🎸 + tag: + the + tag 1 🎸🎸 + - + attributes: + 🎸?: + value + newlines 🎸 + tag: + the + tag 2 🎸🎸 + kodi_safe_title 🎸: kodi_safe_value 🎸 + kodi_safe_title_with_attrs: + attributes: + 🎸?: + value + newlines 🎸 + tag: + the + tag 🎸🎸 + premiered: 2020-08-07 + title: Mock Entry 20-3 + Mock Entry 21-1.info.json + Mock Entry 21-1.jpg + Mock Entry 21-1.mp4 + Video Tags: + album: Music Videos + artist: subscription_test + genre: ytdl-sub + premiered: 2021-08-08 + title: Mock Entry 21-1 + year: 2021 + Mock Entry 21-1.nfo + NFO tags: + musicvideo: + album: Music Videos + artist: subscription_test + genre: ytdl-sub + kodi_safe_multi_title 🎸: + - value 1 🎸 + - value 2 🎸 + kodi_safe_multi_title_with_attrs: + - + attributes: + 🎸?: + value + newlines 🎸 + tag: + the + tag 1 🎸🎸 + - + attributes: + 🎸?: + value + newlines 🎸 + tag: + the + tag 2 🎸🎸 + kodi_safe_title 🎸: kodi_safe_value 🎸 + kodi_safe_title_with_attrs: + attributes: + 🎸?: + value + newlines 🎸 + tag: + the + tag 🎸🎸 + premiered: 2021-08-08 + title: Mock Entry 21-1 \ No newline at end of file diff --git a/tests/resources/transaction_log_summaries/plugins/nfo_tags/test_nfo_kodi_safe.txt b/tests/resources/transaction_log_summaries/plugins/nfo_tags/test_nfo_kodi_safe.txt index 7438981f..55e958bb 100644 --- a/tests/resources/transaction_log_summaries/plugins/nfo_tags/test_nfo_kodi_safe.txt +++ b/tests/resources/transaction_log_summaries/plugins/nfo_tags/test_nfo_kodi_safe.txt @@ -1,7 +1,7 @@ Files created: ---------------------------------------- {output_directory} - .ytdl-sub-kodi_safe_xml-download-archive.json + .ytdl-sub-subscription_test-download-archive.json test.nfo NFO tags: kodi_safe_root □: @@ -34,22 +34,22 @@ Files created: tag: the tag □□ -{output_directory}/kodi_safe_xml - Can you hear the difference? 🎸🔥 #shorts.info.json - Can you hear the difference? 🎸🔥 #shorts.jpg - Can you hear the difference? 🎸🔥 #shorts.mp4 +{output_directory}/subscription_test + Mock Entry 20-1.info.json + Mock Entry 20-1.jpg + Mock Entry 20-1.mp4 Video Tags: album: Music Videos - artist: kodi_safe_xml + artist: subscription_test genre: ytdl-sub - premiered: 2022-06-30 - title: Can you hear the difference? 🎸🔥 #shorts - year: 2022 - Can you hear the difference? 🎸🔥 #shorts.nfo + premiered: 2020-08-08 + title: Mock Entry 20-1 + year: 2020 + Mock Entry 20-1.nfo NFO tags: musicvideo: album: Music Videos - artist: kodi_safe_xml + artist: subscription_test genre: ytdl-sub kodi_safe_multi_title □: - value 1 □ @@ -80,5 +80,146 @@ Files created: tag: the tag □□ - premiered: 2022-06-30 - title: Can you hear the difference? □□ #shorts \ No newline at end of file + premiered: 2020-08-08 + title: Mock Entry 20-1 + Mock Entry 20-2.info.json + Mock Entry 20-2.jpg + Mock Entry 20-2.mp4 + Video Tags: + album: Music Videos + artist: subscription_test + genre: ytdl-sub + premiered: 2020-08-08 + title: Mock Entry 20-2 + year: 2020 + Mock Entry 20-2.nfo + NFO tags: + musicvideo: + album: Music Videos + artist: subscription_test + genre: ytdl-sub + kodi_safe_multi_title □: + - value 1 □ + - value 2 □ + kodi_safe_multi_title_with_attrs: + - + attributes: + □?: + value + newlines □ + tag: + the + tag 1 □□ + - + attributes: + □?: + value + newlines □ + tag: + the + tag 2 □□ + kodi_safe_title □: kodi_safe_value □ + kodi_safe_title_with_attrs: + attributes: + □?: + value + newlines □ + tag: + the + tag □□ + premiered: 2020-08-08 + title: Mock Entry 20-2 + Mock Entry 20-3.info.json + Mock Entry 20-3.jpg + Mock Entry 20-3.mp4 + Video Tags: + album: Music Videos + artist: subscription_test + genre: ytdl-sub + premiered: 2020-08-07 + title: Mock Entry 20-3 + year: 2020 + Mock Entry 20-3.nfo + NFO tags: + musicvideo: + album: Music Videos + artist: subscription_test + genre: ytdl-sub + kodi_safe_multi_title □: + - value 1 □ + - value 2 □ + kodi_safe_multi_title_with_attrs: + - + attributes: + □?: + value + newlines □ + tag: + the + tag 1 □□ + - + attributes: + □?: + value + newlines □ + tag: + the + tag 2 □□ + kodi_safe_title □: kodi_safe_value □ + kodi_safe_title_with_attrs: + attributes: + □?: + value + newlines □ + tag: + the + tag □□ + premiered: 2020-08-07 + title: Mock Entry 20-3 + Mock Entry 21-1.info.json + Mock Entry 21-1.jpg + Mock Entry 21-1.mp4 + Video Tags: + album: Music Videos + artist: subscription_test + genre: ytdl-sub + premiered: 2021-08-08 + title: Mock Entry 21-1 + year: 2021 + Mock Entry 21-1.nfo + NFO tags: + musicvideo: + album: Music Videos + artist: subscription_test + genre: ytdl-sub + kodi_safe_multi_title □: + - value 1 □ + - value 2 □ + kodi_safe_multi_title_with_attrs: + - + attributes: + □?: + value + newlines □ + tag: + the + tag 1 □□ + - + attributes: + □?: + value + newlines □ + tag: + the + tag 2 □□ + kodi_safe_title □: kodi_safe_value □ + kodi_safe_title_with_attrs: + attributes: + □?: + value + newlines □ + tag: + the + tag □□ + premiered: 2021-08-08 + title: Mock Entry 21-1 \ No newline at end of file diff --git a/tests/e2e/plugins/test_nfo_tags.py b/tests/unit/plugins/test_nfo_tags.py similarity index 87% rename from tests/e2e/plugins/test_nfo_tags.py rename to tests/unit/plugins/test_nfo_tags.py index 24e02de2..06a36698 100644 --- a/tests/e2e/plugins/test_nfo_tags.py +++ b/tests/unit/plugins/test_nfo_tags.py @@ -1,5 +1,6 @@ import pytest from expected_transaction_log import assert_transaction_log_matches +from unit.conftest import mock_download_collection_entries from ytdl_sub.subscriptions.subscription import Subscription @@ -8,7 +9,7 @@ from ytdl_sub.subscriptions.subscription import Subscription def subscription_dict(output_directory): return { "preset": "Jellyfin Music Videos", - "download": "https://www.youtube.com/shorts/ucYmEqmlhFw", + "download": "https://your.name.here", # override the output directory with our fixture-generated dir "output_options": {"output_directory": output_directory}, "format": "best[height<=480]", # download the worst format so it is fast @@ -79,7 +80,15 @@ def subscription_dict(output_directory): class TestNfoTagsPlugins: @pytest.mark.parametrize("kodi_safe", [True, False]) - def test_nfo_tags(self, subscription_dict, default_config, output_directory, kodi_safe): + def test_nfo_tags( + self, + subscription_name, + subscription_dict, + config, + output_directory, + mock_download_collection_entries, + kodi_safe, + ): transaction_log_file_name = "test_nfo.txt" if kodi_safe: transaction_log_file_name = "test_nfo_kodi_safe.txt" @@ -87,13 +96,17 @@ class TestNfoTagsPlugins: subscription_dict["output_directory_nfo_tags"]["kodi_safe"] = True subscription = Subscription.from_dict( - config=default_config, - preset_name="kodi_safe_xml", + config=config, + preset_name=subscription_name, preset_dict=subscription_dict, ) # Only dry run is needed to see if NFO values are kodi safe - transaction_log = subscription.download(dry_run=True) + with mock_download_collection_entries( + is_youtube_channel=False, num_urls=1, is_extracted_audio=False + ): + transaction_log = subscription.download(dry_run=False) + assert_transaction_log_matches( output_directory=output_directory, transaction_log=transaction_log,