diff --git a/tests/e2e/plugins/test_audio_extract.py b/tests/e2e/plugins/test_audio_extract.py index 90be1603..4b3a6e2e 100644 --- a/tests/e2e/plugins/test_audio_extract.py +++ b/tests/e2e/plugins/test_audio_extract.py @@ -1,6 +1,7 @@ import pytest from expected_download import assert_expected_downloads from expected_transaction_log import assert_transaction_log_matches +from resources import DISABLE_YOUTUBE_TESTS from ytdl_sub.subscriptions.subscription import Subscription @@ -45,7 +46,9 @@ def youtube_release_preset_dict(output_directory): }, } - +@pytest.mark.skipif( + DISABLE_YOUTUBE_TESTS, reason="YouTube tests cannot run in GH" +) class TestAudioExtract: @pytest.mark.parametrize("dry_run", [False]) def test_audio_extract_single_song( diff --git a/tests/e2e/plugins/test_chapters.py b/tests/e2e/plugins/test_chapters.py index 3a5eed4d..45f427b7 100644 --- a/tests/e2e/plugins/test_chapters.py +++ b/tests/e2e/plugins/test_chapters.py @@ -3,6 +3,7 @@ from typing import Dict import pytest from expected_download import assert_expected_downloads from expected_transaction_log import assert_transaction_log_matches +from resources import DISABLE_YOUTUBE_TESTS from ytdl_sub.subscriptions.subscription import Subscription @@ -53,6 +54,9 @@ def chapters_from_comments_preset_dict(sponsorblock_and_subs_preset_dict: Dict) return sponsorblock_and_subs_preset_dict +@pytest.mark.skipif( + DISABLE_YOUTUBE_TESTS, reason="YouTube tests cannot run in GH" +) class TestChapters: @pytest.mark.parametrize("dry_run", [True, False]) def test_chapters_sponsorblock_and_removal_with_subs( diff --git a/tests/e2e/plugins/test_date_range.py b/tests/e2e/plugins/test_date_range.py index e803fa36..139cdd79 100644 --- a/tests/e2e/plugins/test_date_range.py +++ b/tests/e2e/plugins/test_date_range.py @@ -5,6 +5,7 @@ import pytest from conftest import assert_logs from expected_download import assert_expected_downloads from expected_transaction_log import assert_transaction_log_matches +from resources import DISABLE_YOUTUBE_TESTS from ytdl_sub.downloaders.ytdlp import YTDLP from ytdl_sub.subscriptions.subscription import Subscription @@ -38,6 +39,9 @@ def rolling_recent_channel_preset_dict(recent_preset_dict): ) +@pytest.mark.skipif( + DISABLE_YOUTUBE_TESTS, reason="YouTube tests cannot run in GH" +) class TestDateRange: @pytest.mark.parametrize("dry_run", [True, False]) @pytest.mark.parametrize("date_range_breaks", [True, False]) diff --git a/tests/e2e/plugins/test_file_convert.py b/tests/e2e/plugins/test_file_convert.py index e3a7175c..e4d711fa 100644 --- a/tests/e2e/plugins/test_file_convert.py +++ b/tests/e2e/plugins/test_file_convert.py @@ -1,6 +1,7 @@ import pytest from expected_download import assert_expected_downloads from expected_transaction_log import assert_transaction_log_matches +from resources import DISABLE_YOUTUBE_TESTS from ytdl_sub.subscriptions.subscription import Subscription @@ -19,6 +20,9 @@ def preset_dict(output_directory): } +@pytest.mark.skipif( + DISABLE_YOUTUBE_TESTS, reason="YouTube tests cannot run in GH" +) class TestFileConvert: @pytest.mark.parametrize("dry_run", [True, False]) def test_file_convert( diff --git a/tests/e2e/plugins/test_match_filters.py b/tests/e2e/plugins/test_match_filters.py index 2e669319..4ea43aea 100644 --- a/tests/e2e/plugins/test_match_filters.py +++ b/tests/e2e/plugins/test_match_filters.py @@ -1,6 +1,7 @@ import pytest from expected_download import assert_expected_downloads from expected_transaction_log import assert_transaction_log_matches +from resources import DISABLE_YOUTUBE_TESTS from ytdl_sub.subscriptions.subscription import Subscription @@ -45,6 +46,9 @@ def livestream_preset_dict(output_directory): } +@pytest.mark.skipif( + DISABLE_YOUTUBE_TESTS, reason="YouTube tests cannot run in GH" +) class TestFileConvert: def test_livestreams_download_filtered( self, diff --git a/tests/e2e/plugins/test_split_by_chapters.py b/tests/e2e/plugins/test_split_by_chapters.py index bfa06823..33f84614 100644 --- a/tests/e2e/plugins/test_split_by_chapters.py +++ b/tests/e2e/plugins/test_split_by_chapters.py @@ -4,6 +4,7 @@ import mergedeep import pytest from expected_download import assert_expected_downloads from expected_transaction_log import assert_transaction_log_matches +from resources import DISABLE_YOUTUBE_TESTS from ytdl_sub.subscriptions.subscription import Subscription from ytdl_sub.utils.exceptions import ValidationException @@ -57,6 +58,9 @@ def yt_album_as_chapters_with_regex_preset_dict(yt_album_as_chapters_preset_dict return yt_album_as_chapters_preset_dict +@pytest.mark.skipif( + DISABLE_YOUTUBE_TESTS, reason="YouTube tests cannot run in GH" +) class TestSplitByChapters: @pytest.mark.parametrize("dry_run", [True, False]) def test_video_with_chapters( diff --git a/tests/e2e/plugins/test_subtitles.py b/tests/e2e/plugins/test_subtitles.py index ae5e14e9..fd82112b 100644 --- a/tests/e2e/plugins/test_subtitles.py +++ b/tests/e2e/plugins/test_subtitles.py @@ -1,6 +1,7 @@ import pytest from expected_download import assert_expected_downloads from expected_transaction_log import assert_transaction_log_matches +from resources import DISABLE_YOUTUBE_TESTS from ytdl_sub.config.config_file import ConfigFile from ytdl_sub.subscriptions.subscription import Subscription @@ -31,6 +32,9 @@ def test_single_video_subs_embed_and_file_preset_dict(single_video_subs_embed_pr return single_video_subs_embed_preset_dict +@pytest.mark.skipif( + DISABLE_YOUTUBE_TESTS, reason="YouTube tests cannot run in GH" +) class TestSubtitles: def test_subtitle_lang_variable_partial_validates(self, default_config): default_config_dict = default_config.as_dict() diff --git a/tests/e2e/bandcamp/__init__.py b/tests/e2e/presets/__init__.py similarity index 100% rename from tests/e2e/bandcamp/__init__.py rename to tests/e2e/presets/__init__.py diff --git a/tests/e2e/bandcamp/test_bandcamp.py b/tests/e2e/presets/test_bandcamp.py similarity index 90% rename from tests/e2e/bandcamp/test_bandcamp.py rename to tests/e2e/presets/test_bandcamp.py index c4d410cd..d635aef7 100644 --- a/tests/e2e/bandcamp/test_bandcamp.py +++ b/tests/e2e/presets/test_bandcamp.py @@ -46,12 +46,12 @@ class TestBandcamp: assert_transaction_log_matches( output_directory=output_directory, transaction_log=transaction_log, - transaction_log_summary_file_name="bandcamp/test_artist_url.txt", + transaction_log_summary_file_name="presets/test_artist_url.txt", ) assert_expected_downloads( output_directory=output_directory, dry_run=dry_run, - expected_download_summary_file_name="bandcamp/test_artist_url.json", + expected_download_summary_file_name="presets/test_artist_url.json", ) # Ensure another invocation will hit ExistingVideoReached @@ -67,5 +67,5 @@ class TestBandcamp: assert_expected_downloads( output_directory=output_directory, dry_run=dry_run, - expected_download_summary_file_name="bandcamp/test_artist_url.json", + expected_download_summary_file_name="presets/test_artist_url.json", ) diff --git a/tests/e2e/youtube/test_playlist.py b/tests/e2e/presets/test_bilateral.py similarity index 58% rename from tests/e2e/youtube/test_playlist.py rename to tests/e2e/presets/test_bilateral.py index c3a364a6..b5e7c02f 100644 --- a/tests/e2e/youtube/test_playlist.py +++ b/tests/e2e/presets/test_bilateral.py @@ -1,52 +1,13 @@ from typing import Dict import pytest -from conftest import assert_logs -from expected_download import assert_expected_downloads from expected_transaction_log import assert_transaction_log_matches +from resources import DISABLE_YOUTUBE_TESTS from ytdl_sub.config.config_file import ConfigFile -from ytdl_sub.downloaders.ytdlp import YTDLP from ytdl_sub.subscriptions.subscription import Subscription -@pytest.fixture -def playlist_preset_dict(output_directory): - return { - "preset": [ - "jellyfin_tv_show_collection", - "season_by_collection__episode_by_year_month_day", - "collection_season_1", - ], - "format": "worst[ext=mp4]", # download the worst format so it is fast - "output_directory_nfo_tags": { - "nfo_name": "tvshow.nfo", - "nfo_root": "test", - "tags": { - "playlist_title": "{playlist_title}", - "playlist_uploader": "{playlist_uploader}", - "playlist_description": "{playlist_description}", - }, - }, - "nfo_tags": { - "tags": { - "playlist_index": "{playlist_index}", - "playlist_count": "{playlist_count}", - } - }, - "subtitles": { - "subtitles_name": "{episode_file_path}.{lang}.{subtitles_ext}", - "allow_auto_generated_subtitles": True, - }, - "overrides": { - "tv_show_name": "JMC", - "tv_show_directory": output_directory, - "collection_season_1_url": "https://youtube.com/playlist?list=PL5BC0FC26BECA5A35", - "collection_season_1_name": "JMC - Season 1", - }, - } - - @pytest.fixture def tv_show_by_date_bilateral_dict(output_directory): return { @@ -90,53 +51,10 @@ def tv_show_collection_bilateral_dict(output_directory): } -class TestPlaylist: - """ - Downloads my old minecraft youtube channel, pretends they are music videos. Ensure the above - files exist and have the expected md5 file hashes. - """ - - @pytest.mark.parametrize("dry_run", [True, False]) - def test_playlist_download( - self, - default_config, - playlist_preset_dict, - output_directory, - dry_run, - ): - playlist_subscription = Subscription.from_dict( - config=default_config, - preset_name="music_video_playlist_test", - preset_dict=playlist_preset_dict, - ) - - transaction_log = playlist_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_playlist.txt", - ) - assert_expected_downloads( - output_directory=output_directory, - dry_run=dry_run, - expected_download_summary_file_name="youtube/test_playlist.json", - ) - - # Ensure another invocation will hit ExistingVideoReached - if not dry_run: - with assert_logs( - logger=YTDLP.logger, - expected_message="ExistingVideoReached, stopping additional downloads", - log_level="debug", - ): - transaction_log = playlist_subscription.download() - - assert transaction_log.is_empty - assert_expected_downloads( - output_directory=output_directory, - dry_run=dry_run, - expected_download_summary_file_name="youtube/test_playlist.json", - ) +@pytest.mark.skipif( + DISABLE_YOUTUBE_TESTS, reason="YouTube tests cannot run in GH" +) +class TestBilateral: def test_tv_show_by_date_downloads_bilateral( self, diff --git a/tests/e2e/soundcloud/test_soundcloud_discography.py b/tests/e2e/presets/test_soundcloud.py similarity index 100% rename from tests/e2e/soundcloud/test_soundcloud_discography.py rename to tests/e2e/presets/test_soundcloud.py diff --git a/tests/e2e/soundcloud/__init__.py b/tests/e2e/soundcloud/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/e2e/youtube/test_channel.py b/tests/e2e/youtube/test_channel.py index 4ed9fe20..02c103ff 100644 --- a/tests/e2e/youtube/test_channel.py +++ b/tests/e2e/youtube/test_channel.py @@ -4,6 +4,7 @@ from typing import Dict import pytest from expected_download import assert_expected_downloads from expected_transaction_log import assert_transaction_log_matches +from resources import DISABLE_YOUTUBE_TESTS from ytdl_sub.config.config_file import ConfigFile from ytdl_sub.subscriptions.subscription import Subscription @@ -42,6 +43,9 @@ def channel_preset_dict(output_directory): } +@pytest.mark.skipif( + DISABLE_YOUTUBE_TESTS, reason="YouTube tests cannot run in GH" +) class TestChannel: """ Downloads my old minecraft youtube channel. Ensure the above files exist and have the diff --git a/tests/e2e/youtube/test_video.py b/tests/e2e/youtube/test_video.py index 10b4e974..2964f95b 100644 --- a/tests/e2e/youtube/test_video.py +++ b/tests/e2e/youtube/test_video.py @@ -1,7 +1,7 @@ import pytest -from conftest import preset_dict_to_dl_args from expected_download import assert_expected_downloads from expected_transaction_log import assert_transaction_log_matches +from resources import DISABLE_YOUTUBE_TESTS from ytdl_sub.subscriptions.subscription import Subscription @@ -29,12 +29,9 @@ def single_video_preset_dict(output_directory): }, } - -@pytest.fixture -def single_video_preset_dict_dl_args(single_video_preset_dict): - return preset_dict_to_dl_args(single_video_preset_dict) - - +@pytest.mark.skipif( + DISABLE_YOUTUBE_TESTS, reason="YouTube tests cannot run in GH" +) class TestYoutubeVideo: @pytest.mark.parametrize("dry_run", [True, False]) def test_single_video_download( diff --git a/tests/resources.py b/tests/resources.py index 8a426c9e..c1aa18d4 100644 --- a/tests/resources.py +++ b/tests/resources.py @@ -2,6 +2,7 @@ import os import shutil from pathlib import Path +DISABLE_YOUTUBE_TESTS: bool = True REGENERATE_FIXTURES: bool = False RESOURCE_PATH: Path = Path("tests") / "resources"