[DEV] OutputOptions unit tests (#1078)
This commit is contained in:
parent
2417bec691
commit
648201ed9c
6 changed files with 200 additions and 54 deletions
|
|
@ -29,8 +29,6 @@ def single_video_preset_dict(output_directory):
|
|||
"video_tags": {
|
||||
"title": "{title}",
|
||||
},
|
||||
# And test subscription download proba = 1.0
|
||||
"throttle_protection": {"subscription_download_probability": 1.0},
|
||||
"overrides": {
|
||||
"music_video_artist": "JMC",
|
||||
"music_video_directory": output_directory,
|
||||
|
|
@ -40,38 +38,6 @@ def single_video_preset_dict(output_directory):
|
|||
}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def single_tv_show_video_nulled_values_preset_dict(output_directory):
|
||||
return {
|
||||
"preset": [
|
||||
"jellyfin_tv_show_by_date",
|
||||
"season_by_year__episode_by_download_index",
|
||||
"chunk_initial_download",
|
||||
],
|
||||
# set file output fields to None
|
||||
"output_options": {
|
||||
"thumbnail_name": "",
|
||||
"info_json_name": "",
|
||||
},
|
||||
"format": "worst[ext=mp4]",
|
||||
"ytdl_options": {
|
||||
"max_downloads": 2,
|
||||
},
|
||||
# test override variables added by ytdl-sub
|
||||
"nfo_tags": {
|
||||
"tags": {
|
||||
"subscription_name": "{subscription_name}",
|
||||
"subscription_name_sanitized": "{subscription_name_sanitized}",
|
||||
}
|
||||
},
|
||||
"overrides": {
|
||||
"url": "https://www.youtube.com/@ProjectZombie603",
|
||||
"tv_show_name": "Project Zombie",
|
||||
"tv_show_directory": 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)
|
||||
|
|
@ -172,22 +138,3 @@ class TestYoutubeVideo:
|
|||
dry_run=dry_run,
|
||||
expected_download_summary_file_name="youtube/test_video_cli.json",
|
||||
)
|
||||
|
||||
def test_single_video_nulled_values(
|
||||
self,
|
||||
tv_show_config,
|
||||
single_tv_show_video_nulled_values_preset_dict,
|
||||
output_directory,
|
||||
):
|
||||
single_video_subscription = Subscription.from_dict(
|
||||
config=tv_show_config,
|
||||
preset_name="tv_video_nulled_values",
|
||||
preset_dict=single_tv_show_video_nulled_values_preset_dict,
|
||||
)
|
||||
|
||||
transaction_log = single_video_subscription.download(dry_run=True)
|
||||
assert_transaction_log_matches(
|
||||
output_directory=output_directory,
|
||||
transaction_log=transaction_log,
|
||||
transaction_log_summary_file_name="youtube/test_video_nulled_values.txt",
|
||||
)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
".ytdl-sub-subscription_test-download-archive.json": "7c6fbd0631d7d02025f3da457ba203e3",
|
||||
"Season 2020/s2020.e000001 - Mock Entry 20-3.mp4": "7d2ee7fe8003ea63ece37dd2a441c123",
|
||||
"Season 2020/s2020.e000001 - Mock Entry 20-3.nfo": "dbe61f2c8ae41041773f713ba5376726",
|
||||
"Season 2020/s2020.e000002 - Mock Entry 20-2.mp4": "699017cd1b67ae216eda769bef413415",
|
||||
"Season 2020/s2020.e000002 - Mock Entry 20-2.nfo": "0f071078c9fa2569bbcb998664d40681",
|
||||
"Season 2020/s2020.e000003 - Mock Entry 20-1.mp4": "a16741d4fbf657d1de4c50493db14062",
|
||||
"Season 2020/s2020.e000003 - Mock Entry 20-1.nfo": "837a61dca11bbe1874ea07cb8ef8a7c9",
|
||||
"Season 2021/s2021.e000004 - Mock Entry 21-1.mp4": "7433153952b069a5674e2a3ed529b49b",
|
||||
"Season 2021/s2021.e000004 - Mock Entry 21-1.nfo": "8ee3845c514a411425b7e9198666b61c",
|
||||
"tvshow.nfo": "cccca1086b41af04d8ea004b1aa250e8"
|
||||
}
|
||||
|
|
@ -0,0 +1,120 @@
|
|||
Files created:
|
||||
----------------------------------------
|
||||
{output_directory}
|
||||
.ytdl-sub-subscription_test-download-archive.json
|
||||
tvshow.nfo
|
||||
NFO tags:
|
||||
tvshow:
|
||||
genre: ytdl-sub
|
||||
mpaa: TV-14
|
||||
title: JMC
|
||||
{output_directory}/Season 2020
|
||||
s2020.e000001 - Mock Entry 20-3.mp4
|
||||
Video Tags:
|
||||
contentRating: TV-14
|
||||
date: 2020-08-07
|
||||
episode_id: 1
|
||||
genre: ytdl-sub
|
||||
show: JMC
|
||||
synopsis:
|
||||
https://20-3.com
|
||||
|
||||
The Description
|
||||
title: 2020-08-07 - Mock Entry 20-3
|
||||
year: 2020
|
||||
s2020.e000001 - Mock Entry 20-3.nfo
|
||||
NFO tags:
|
||||
episodedetails:
|
||||
aired: 2020-08-07
|
||||
episode: 1
|
||||
genre: ytdl-sub
|
||||
mpaa: TV-14
|
||||
plot:
|
||||
https://20-3.com
|
||||
|
||||
The Description
|
||||
season: 2020
|
||||
title: 2020-08-07 - Mock Entry 20-3
|
||||
year: 2020
|
||||
s2020.e000002 - Mock Entry 20-2.mp4
|
||||
Video Tags:
|
||||
contentRating: TV-14
|
||||
date: 2020-08-08
|
||||
episode_id: 2
|
||||
genre: ytdl-sub
|
||||
show: JMC
|
||||
synopsis:
|
||||
https://20-2.com
|
||||
|
||||
The Description
|
||||
title: 2020-08-08 - Mock Entry 20-2
|
||||
year: 2020
|
||||
s2020.e000002 - Mock Entry 20-2.nfo
|
||||
NFO tags:
|
||||
episodedetails:
|
||||
aired: 2020-08-08
|
||||
episode: 2
|
||||
genre: ytdl-sub
|
||||
mpaa: TV-14
|
||||
plot:
|
||||
https://20-2.com
|
||||
|
||||
The Description
|
||||
season: 2020
|
||||
title: 2020-08-08 - Mock Entry 20-2
|
||||
year: 2020
|
||||
s2020.e000003 - Mock Entry 20-1.mp4
|
||||
Video Tags:
|
||||
contentRating: TV-14
|
||||
date: 2020-08-08
|
||||
episode_id: 3
|
||||
genre: ytdl-sub
|
||||
show: JMC
|
||||
synopsis:
|
||||
https://20-1.com
|
||||
|
||||
The Description
|
||||
title: 2020-08-08 - Mock Entry 20-1
|
||||
year: 2020
|
||||
s2020.e000003 - Mock Entry 20-1.nfo
|
||||
NFO tags:
|
||||
episodedetails:
|
||||
aired: 2020-08-08
|
||||
episode: 3
|
||||
genre: ytdl-sub
|
||||
mpaa: TV-14
|
||||
plot:
|
||||
https://20-1.com
|
||||
|
||||
The Description
|
||||
season: 2020
|
||||
title: 2020-08-08 - Mock Entry 20-1
|
||||
year: 2020
|
||||
{output_directory}/Season 2021
|
||||
s2021.e000004 - Mock Entry 21-1.mp4
|
||||
Video Tags:
|
||||
contentRating: TV-14
|
||||
date: 2021-08-08
|
||||
episode_id: 4
|
||||
genre: ytdl-sub
|
||||
show: JMC
|
||||
synopsis:
|
||||
https://21-1.com
|
||||
|
||||
The Description
|
||||
title: 2021-08-08 - Mock Entry 21-1
|
||||
year: 2021
|
||||
s2021.e000004 - Mock Entry 21-1.nfo
|
||||
NFO tags:
|
||||
episodedetails:
|
||||
aired: 2021-08-08
|
||||
episode: 4
|
||||
genre: ytdl-sub
|
||||
mpaa: TV-14
|
||||
plot:
|
||||
https://21-1.com
|
||||
|
||||
The Description
|
||||
season: 2021
|
||||
title: 2021-08-08 - Mock Entry 21-1
|
||||
year: 2021
|
||||
|
|
@ -25,7 +25,7 @@ def file_convert_subscription_dict(output_directory) -> Dict:
|
|||
}
|
||||
|
||||
|
||||
class TestChapters:
|
||||
class TestFileConvert:
|
||||
@pytest.mark.parametrize("dry_run", [True, False])
|
||||
def test_file_convert_custom_args(
|
||||
self,
|
||||
|
|
|
|||
66
tests/unit/plugins/test_output_options.py
Normal file
66
tests/unit/plugins/test_output_options.py
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
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.config.config_file import ConfigFile
|
||||
from ytdl_sub.subscriptions.subscription import Subscription
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def output_options_subscription_dict(output_directory) -> Dict:
|
||||
return {
|
||||
"preset": [
|
||||
"jellyfin_tv_show_by_date",
|
||||
"season_by_year__episode_by_download_index",
|
||||
"chunk_initial_download",
|
||||
],
|
||||
"output_options": {
|
||||
"output_directory": output_directory,
|
||||
},
|
||||
"overrides": {
|
||||
"tv_show_name": "JMC",
|
||||
"url": "https://your.name.here",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
class TestOutputOptions:
|
||||
@pytest.mark.parametrize("dry_run", [True, False])
|
||||
def test_empty_info_json_and_thumb(
|
||||
self,
|
||||
config: ConfigFile,
|
||||
subscription_name: str,
|
||||
output_options_subscription_dict: Dict,
|
||||
output_directory: str,
|
||||
mock_download_collection_entries,
|
||||
dry_run,
|
||||
):
|
||||
output_options_subscription_dict["output_options"]["thumbnail_name"] = ""
|
||||
output_options_subscription_dict["output_options"]["info_json_name"] = ""
|
||||
|
||||
subscription = Subscription.from_dict(
|
||||
config=config,
|
||||
preset_name=subscription_name,
|
||||
preset_dict=output_options_subscription_dict,
|
||||
)
|
||||
|
||||
with mock_download_collection_entries(
|
||||
is_youtube_channel=False,
|
||||
num_urls=1,
|
||||
is_extracted_audio=False,
|
||||
is_dry_run=dry_run,
|
||||
):
|
||||
transaction_log = subscription.download(dry_run=dry_run)
|
||||
|
||||
assert_transaction_log_matches(
|
||||
output_directory=output_directory,
|
||||
transaction_log=transaction_log,
|
||||
transaction_log_summary_file_name="plugins/output_options/empty_info_json_thumb.txt",
|
||||
)
|
||||
assert_expected_downloads(
|
||||
output_directory=output_directory,
|
||||
dry_run=dry_run,
|
||||
expected_download_summary_file_name="plugins/output_options/empty_info_json_thumb.json",
|
||||
)
|
||||
|
|
@ -28,6 +28,7 @@ def throttle_subscription_dict(output_directory) -> Dict:
|
|||
"min": 0.02,
|
||||
"max": 0.02,
|
||||
},
|
||||
"subscription_download_probability": 1.0,
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue