[DEV] Disable YouTube tests in GH CLI

This commit is contained in:
Jesse Bannon 2024-10-07 23:15:09 -07:00
parent 1499d7486c
commit ee60b15549
15 changed files with 45 additions and 98 deletions

View file

@ -1,6 +1,7 @@
import pytest import pytest
from expected_download import assert_expected_downloads from expected_download import assert_expected_downloads
from expected_transaction_log import assert_transaction_log_matches 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.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: class TestAudioExtract:
@pytest.mark.parametrize("dry_run", [False]) @pytest.mark.parametrize("dry_run", [False])
def test_audio_extract_single_song( def test_audio_extract_single_song(

View file

@ -3,6 +3,7 @@ from typing import Dict
import pytest import pytest
from expected_download import assert_expected_downloads from expected_download import assert_expected_downloads
from expected_transaction_log import assert_transaction_log_matches 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.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 return sponsorblock_and_subs_preset_dict
@pytest.mark.skipif(
DISABLE_YOUTUBE_TESTS, reason="YouTube tests cannot run in GH"
)
class TestChapters: class TestChapters:
@pytest.mark.parametrize("dry_run", [True, False]) @pytest.mark.parametrize("dry_run", [True, False])
def test_chapters_sponsorblock_and_removal_with_subs( def test_chapters_sponsorblock_and_removal_with_subs(

View file

@ -5,6 +5,7 @@ import pytest
from conftest import assert_logs from conftest import assert_logs
from expected_download import assert_expected_downloads from expected_download import assert_expected_downloads
from expected_transaction_log import assert_transaction_log_matches 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.downloaders.ytdlp import YTDLP
from ytdl_sub.subscriptions.subscription import Subscription 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: class TestDateRange:
@pytest.mark.parametrize("dry_run", [True, False]) @pytest.mark.parametrize("dry_run", [True, False])
@pytest.mark.parametrize("date_range_breaks", [True, False]) @pytest.mark.parametrize("date_range_breaks", [True, False])

View file

@ -1,6 +1,7 @@
import pytest import pytest
from expected_download import assert_expected_downloads from expected_download import assert_expected_downloads
from expected_transaction_log import assert_transaction_log_matches 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.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: class TestFileConvert:
@pytest.mark.parametrize("dry_run", [True, False]) @pytest.mark.parametrize("dry_run", [True, False])
def test_file_convert( def test_file_convert(

View file

@ -1,6 +1,7 @@
import pytest import pytest
from expected_download import assert_expected_downloads from expected_download import assert_expected_downloads
from expected_transaction_log import assert_transaction_log_matches 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.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: class TestFileConvert:
def test_livestreams_download_filtered( def test_livestreams_download_filtered(
self, self,

View file

@ -4,6 +4,7 @@ import mergedeep
import pytest import pytest
from expected_download import assert_expected_downloads from expected_download import assert_expected_downloads
from expected_transaction_log import assert_transaction_log_matches 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.subscriptions.subscription import Subscription
from ytdl_sub.utils.exceptions import ValidationException 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 return yt_album_as_chapters_preset_dict
@pytest.mark.skipif(
DISABLE_YOUTUBE_TESTS, reason="YouTube tests cannot run in GH"
)
class TestSplitByChapters: class TestSplitByChapters:
@pytest.mark.parametrize("dry_run", [True, False]) @pytest.mark.parametrize("dry_run", [True, False])
def test_video_with_chapters( def test_video_with_chapters(

View file

@ -1,6 +1,7 @@
import pytest import pytest
from expected_download import assert_expected_downloads from expected_download import assert_expected_downloads
from expected_transaction_log import assert_transaction_log_matches 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.config.config_file import ConfigFile
from ytdl_sub.subscriptions.subscription import Subscription 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 return single_video_subs_embed_preset_dict
@pytest.mark.skipif(
DISABLE_YOUTUBE_TESTS, reason="YouTube tests cannot run in GH"
)
class TestSubtitles: class TestSubtitles:
def test_subtitle_lang_variable_partial_validates(self, default_config): def test_subtitle_lang_variable_partial_validates(self, default_config):
default_config_dict = default_config.as_dict() default_config_dict = default_config.as_dict()

View file

@ -46,12 +46,12 @@ class TestBandcamp:
assert_transaction_log_matches( assert_transaction_log_matches(
output_directory=output_directory, output_directory=output_directory,
transaction_log=transaction_log, 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( assert_expected_downloads(
output_directory=output_directory, output_directory=output_directory,
dry_run=dry_run, 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 # Ensure another invocation will hit ExistingVideoReached
@ -67,5 +67,5 @@ class TestBandcamp:
assert_expected_downloads( assert_expected_downloads(
output_directory=output_directory, output_directory=output_directory,
dry_run=dry_run, dry_run=dry_run,
expected_download_summary_file_name="bandcamp/test_artist_url.json", expected_download_summary_file_name="presets/test_artist_url.json",
) )

View file

@ -1,52 +1,13 @@
from typing import Dict from typing import Dict
import pytest import pytest
from conftest import assert_logs
from expected_download import assert_expected_downloads
from expected_transaction_log import assert_transaction_log_matches 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.config.config_file import ConfigFile
from ytdl_sub.downloaders.ytdlp import YTDLP
from ytdl_sub.subscriptions.subscription import Subscription 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 @pytest.fixture
def tv_show_by_date_bilateral_dict(output_directory): def tv_show_by_date_bilateral_dict(output_directory):
return { return {
@ -90,53 +51,10 @@ def tv_show_collection_bilateral_dict(output_directory):
} }
class TestPlaylist: @pytest.mark.skipif(
""" DISABLE_YOUTUBE_TESTS, reason="YouTube tests cannot run in GH"
Downloads my old minecraft youtube channel, pretends they are music videos. Ensure the above )
files exist and have the expected md5 file hashes. class TestBilateral:
"""
@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",
)
def test_tv_show_by_date_downloads_bilateral( def test_tv_show_by_date_downloads_bilateral(
self, self,

View file

@ -4,6 +4,7 @@ from typing import Dict
import pytest import pytest
from expected_download import assert_expected_downloads from expected_download import assert_expected_downloads
from expected_transaction_log import assert_transaction_log_matches 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.config.config_file import ConfigFile
from ytdl_sub.subscriptions.subscription import Subscription 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: class TestChannel:
""" """
Downloads my old minecraft youtube channel. Ensure the above files exist and have the Downloads my old minecraft youtube channel. Ensure the above files exist and have the

View file

@ -1,7 +1,7 @@
import pytest import pytest
from conftest import preset_dict_to_dl_args
from expected_download import assert_expected_downloads from expected_download import assert_expected_downloads
from expected_transaction_log import assert_transaction_log_matches 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.subscriptions.subscription import Subscription
@ -29,12 +29,9 @@ def single_video_preset_dict(output_directory):
}, },
} }
@pytest.mark.skipif(
@pytest.fixture DISABLE_YOUTUBE_TESTS, reason="YouTube tests cannot run in GH"
def single_video_preset_dict_dl_args(single_video_preset_dict): )
return preset_dict_to_dl_args(single_video_preset_dict)
class TestYoutubeVideo: class TestYoutubeVideo:
@pytest.mark.parametrize("dry_run", [True, False]) @pytest.mark.parametrize("dry_run", [True, False])
def test_single_video_download( def test_single_video_download(

View file

@ -2,6 +2,7 @@ import os
import shutil import shutil
from pathlib import Path from pathlib import Path
DISABLE_YOUTUBE_TESTS: bool = True
REGENERATE_FIXTURES: bool = False REGENERATE_FIXTURES: bool = False
RESOURCE_PATH: Path = Path("tests") / "resources" RESOURCE_PATH: Path = Path("tests") / "resources"