Skip to content

Commit

Permalink
[DEV] Disable YouTube tests in GH CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
jmbannon committed Oct 8, 2024
1 parent 1499d74 commit ee60b15
Show file tree
Hide file tree
Showing 15 changed files with 45 additions and 98 deletions.
5 changes: 4 additions & 1 deletion tests/e2e/plugins/test_audio_extract.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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(
Expand Down
4 changes: 4 additions & 0 deletions tests/e2e/plugins/test_chapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,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

Expand Down Expand Up @@ -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(
Expand Down
4 changes: 4 additions & 0 deletions tests/e2e/plugins/test_date_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
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
Expand Down Expand Up @@ -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])
Expand Down
4 changes: 4 additions & 0 deletions tests/e2e/plugins/test_file_convert.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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(
Expand Down
4 changes: 4 additions & 0 deletions tests/e2e/plugins/test_match_filters.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions tests/e2e/plugins/test_split_by_chapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,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
from ytdl_sub.utils.exceptions import ValidationException
Expand Down Expand Up @@ -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(
Expand Down
4 changes: 4 additions & 0 deletions tests/e2e/plugins/test_subtitles.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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()
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ def test_prebuilt_preset_download(
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
Expand All @@ -67,5 +67,5 @@ def test_prebuilt_preset_download(
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",
)
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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,
Expand Down
File renamed without changes.
Empty file removed tests/e2e/soundcloud/__init__.py
Empty file.
4 changes: 4 additions & 0 deletions tests/e2e/youtube/test_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,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
Expand Down Expand Up @@ -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
Expand Down
11 changes: 4 additions & 7 deletions tests/e2e/youtube/test_video.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions tests/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import shutil
from pathlib import Path

DISABLE_YOUTUBE_TESTS: bool = True
REGENERATE_FIXTURES: bool = False

RESOURCE_PATH: Path = Path("tests") / "resources"
Expand Down

0 comments on commit ee60b15

Please sign in to comment.