Skip to content

Commit

Permalink
no more powerset
Browse files Browse the repository at this point in the history
  • Loading branch information
jmbannon committed Oct 1, 2024
1 parent 617fa49 commit ac37f7e
Show file tree
Hide file tree
Showing 6 changed files with 363 additions and 406 deletions.
8 changes: 8 additions & 0 deletions src/ytdl_sub/prebuilt_presets/tv_show/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ class TvShowByDateEpisodeFormattingPresets(PrebuiltPresets):


class TvShowCollectionPresets(PrebuiltPresets):
preset_names = {
"Kodi TV Show Collection",
"Jellyfin TV Show Collection",
"Plex TV Show Collection",
}


class TvShowCollectionOldPresets(PrebuiltPresets):
preset_names = {
"kodi_tv_show_collection",
"jellyfin_tv_show_collection",
Expand Down
56 changes: 56 additions & 0 deletions tests/integration/prebuilt_presets/test_music.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import pytest
from expected_download import assert_expected_downloads
from expected_transaction_log import assert_transaction_log_matches

from ytdl_sub.prebuilt_presets.music import MusicPresets
from ytdl_sub.subscriptions.subscription import Subscription


@pytest.mark.parametrize("music_preset", MusicPresets.preset_names)
class TestPrebuiltMusicPresets:

def test_presets_run(
self,
config,
subscription_name,
output_directory,
mock_download_collection_entries,
music_preset: str,
):
expected_summary_name = f"unit/music/{music_preset}"

preset_dict = {
"preset": [
music_preset,
],
"overrides": {
"url": "https://your.name.here",
"music_directory": output_directory,
},
}

subscription = Subscription.from_dict(
config=config,
preset_name=subscription_name,
preset_dict=preset_dict,
)

num_urls = 1
if music_preset == "SoundCloud Discography":
num_urls = 2 # simulate /albums and /tracks

with mock_download_collection_entries(
is_youtube_channel=False, num_urls=num_urls, is_extracted_audio=True
):
transaction_log = subscription.download(dry_run=False)

assert_transaction_log_matches(
output_directory=output_directory,
transaction_log=transaction_log,
transaction_log_summary_file_name=f"{expected_summary_name}.txt",
)
assert_expected_downloads(
output_directory=output_directory,
dry_run=False,
expected_download_summary_file_name=f"{expected_summary_name}.json",
)
125 changes: 125 additions & 0 deletions tests/integration/prebuilt_presets/test_music_videos.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
from pathlib import Path
from typing import Dict

import pytest
from expected_download import assert_expected_downloads
from expected_transaction_log import assert_transaction_log_matches

from ytdl_sub.prebuilt_presets.music_videos import MusicVideoPresets
from ytdl_sub.subscriptions.subscription import Subscription


@pytest.mark.parametrize("music_video_preset", MusicVideoPresets.preset_names)
class TestPrebuiltMusicVideoPresets:
def test_presets_run(
self,
config,
subscription_name,
output_directory,
mock_download_collection_entries,
music_video_preset: str,
):
expected_summary_name = f"unit/music_videos/{music_video_preset}"

preset_dict = {
"preset": [
music_video_preset,
],
"overrides": {
"url": "https://your.name.here",
"music_video_directory": output_directory,
},
}

subscription = Subscription.from_dict(
config=config,
preset_name=subscription_name,
preset_dict=preset_dict,
)

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,
transaction_log_summary_file_name=f"{expected_summary_name}.txt",
)
assert_expected_downloads(
output_directory=output_directory,
dry_run=False,
expected_download_summary_file_name=f"{expected_summary_name}.json",
)


@pytest.mark.parametrize("music_video_preset", MusicVideoPresets.preset_names)
@pytest.mark.parametrize("multi_url", [True, False])
class TestPrebuiltMusicVideoPresetsWithCategories:

def _preset_dict(
self,
output_directory: Path,
music_video_preset: str,
multi_url: bool,
) -> Dict:
subscription_dict = {"Music Videos": ["https://your.name.here"]}

if multi_url:
subscription_dict["Concerts"] = [
{"url": "https://your.name.here2", "title": "Custom Title"}
]

preset_dict = {
"preset": [
music_video_preset,
],
"overrides": {
"music_video_directory": output_directory,
"subscription_map": subscription_dict,
},
}

return preset_dict

def test_presets_run(
self,
config,
subscription_name,
output_directory,
mock_download_collection_entries,
music_video_preset: str,
multi_url: bool,
):
expected_summary_name = (
f"unit/music_videos/{music_video_preset} Categorized/multi_url_{multi_url}"
)

preset_dict = self._preset_dict(
output_directory=output_directory,
music_video_preset=music_video_preset,
multi_url=multi_url,
)

subscription = Subscription.from_dict(
config=config,
preset_name=subscription_name,
preset_dict=preset_dict,
)

with mock_download_collection_entries(
is_youtube_channel=False, num_urls=2 if multi_url else 1, is_extracted_audio=False
):
transaction_log = subscription.download(dry_run=False)

assert_transaction_log_matches(
output_directory=output_directory,
transaction_log=transaction_log,
transaction_log_summary_file_name=f"{expected_summary_name}.txt",
)
assert_expected_downloads(
output_directory=output_directory,
dry_run=False,
expected_download_summary_file_name=f"{expected_summary_name}.json",
)
Loading

0 comments on commit ac37f7e

Please sign in to comment.