-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
11 changed files
with
189 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
from typing import Dict | ||
from unittest.mock import patch | ||
|
||
import pytest | ||
|
||
from conftest import preset_dict_to_dl_args, mock_run_from_cli | ||
from expected_download import assert_expected_downloads | ||
from expected_transaction_log import assert_transaction_log_matches | ||
from ytdl_sub.cli.parsers.dl import DownloadArgsParser | ||
|
||
from ytdl_sub.utils.system import IS_WINDOWS | ||
|
||
|
||
@pytest.fixture | ||
def dl_subscription_dict(output_directory) -> Dict: | ||
return { | ||
"preset": "Jellyfin Music Videos", | ||
"overrides": { | ||
"music_video_artist": "JMC", | ||
"music_video_directory": output_directory, | ||
"url": "https://your.name.here", | ||
}, | ||
} | ||
|
||
|
||
class TestCliDl: | ||
@pytest.mark.parametrize("dry_run", [True, False]) | ||
def test_cli_dl_command( | ||
self, | ||
default_config_path: str, | ||
subscription_name: str, | ||
dl_subscription_dict: Dict, | ||
output_directory: str, | ||
mock_download_collection_entries, | ||
dry_run, | ||
): | ||
# TODO: Fix CLI parsing on windows when dealing with spaces | ||
if IS_WINDOWS: | ||
return | ||
|
||
args = "--dry-run " if dry_run else "" | ||
args += f"--config {default_config_path} " | ||
args += f"dl {preset_dict_to_dl_args(dl_subscription_dict)} " | ||
|
||
with ( | ||
patch.object(DownloadArgsParser, "get_dl_subscription_name") as mock_subscription_name, | ||
mock_download_collection_entries( | ||
is_youtube_channel=False, | ||
num_urls=1, | ||
is_extracted_audio=False, | ||
is_dry_run=dry_run, | ||
)): | ||
mock_subscription_name.return_value = subscription_name | ||
subscriptions = mock_run_from_cli(args=args) | ||
|
||
assert_transaction_log_matches( | ||
output_directory=output_directory, | ||
transaction_log=subscriptions[0].transaction_log, | ||
transaction_log_summary_file_name="dl/test_cli_dl_command.txt", | ||
) | ||
assert_expected_downloads( | ||
output_directory=output_directory, | ||
dry_run=dry_run, | ||
expected_download_summary_file_name="dl/test_cli_dl_command.json", | ||
) |
19 changes: 19 additions & 0 deletions
19
tests/resources/expected_downloads_summaries/dl/test_cli_dl_command.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
".ytdl-sub-subscription_test-download-archive.json": "76e202bd03ceef93daaffffee2cfa193", | ||
"JMC/Mock Entry 20-1.info.json": "INFO_JSON", | ||
"JMC/Mock Entry 20-1.jpg": "e80c508c4818454300133fe1dc1a9cd7", | ||
"JMC/Mock Entry 20-1.mp4": "dbaeb2a3bfd1de1c7e9615e8bdacb910", | ||
"JMC/Mock Entry 20-1.nfo": "fefcf0b3e4f4ff80ad636584d50dadec", | ||
"JMC/Mock Entry 20-2.info.json": "INFO_JSON", | ||
"JMC/Mock Entry 20-2.jpg": "e80c508c4818454300133fe1dc1a9cd7", | ||
"JMC/Mock Entry 20-2.mp4": "76c2c70572489c684923a51cb1b50687", | ||
"JMC/Mock Entry 20-2.nfo": "025c0b631da5ff5470382b38fce78d2d", | ||
"JMC/Mock Entry 20-3.info.json": "INFO_JSON", | ||
"JMC/Mock Entry 20-3.jpg": "e80c508c4818454300133fe1dc1a9cd7", | ||
"JMC/Mock Entry 20-3.mp4": "7bb4f21d59a6fb91836537b27a24e776", | ||
"JMC/Mock Entry 20-3.nfo": "618b0ff948d9de2e10cf1da8c0dd6615", | ||
"JMC/Mock Entry 21-1.info.json": "INFO_JSON", | ||
"JMC/Mock Entry 21-1.jpg": "e80c508c4818454300133fe1dc1a9cd7", | ||
"JMC/Mock Entry 21-1.mp4": "7b008531ca5660b51fb8adc83c799084", | ||
"JMC/Mock Entry 21-1.nfo": "e5c715749efc1603a6e2f59244d87aba" | ||
} |
77 changes: 77 additions & 0 deletions
77
tests/resources/transaction_log_summaries/dl/test_cli_dl_command.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
Files created: | ||
---------------------------------------- | ||
{output_directory} | ||
.ytdl-sub-subscription_test-download-archive.json | ||
{output_directory}/JMC | ||
Mock Entry 20-1.info.json | ||
Mock Entry 20-1.jpg | ||
Mock Entry 20-1.mp4 | ||
Video Tags: | ||
album: Music Videos | ||
artist: JMC | ||
genre: ytdl-sub | ||
premiered: 2020-08-08 | ||
title: Mock Entry 20-1 | ||
year: 2020 | ||
Mock Entry 20-1.nfo | ||
NFO tags: | ||
musicvideo: | ||
album: Music Videos | ||
artist: JMC | ||
genre: ytdl-sub | ||
premiered: 2020-08-08 | ||
title: Mock Entry 20-1 | ||
Mock Entry 20-2.info.json | ||
Mock Entry 20-2.jpg | ||
Mock Entry 20-2.mp4 | ||
Video Tags: | ||
album: Music Videos | ||
artist: JMC | ||
genre: ytdl-sub | ||
premiered: 2020-08-08 | ||
title: Mock Entry 20-2 | ||
year: 2020 | ||
Mock Entry 20-2.nfo | ||
NFO tags: | ||
musicvideo: | ||
album: Music Videos | ||
artist: JMC | ||
genre: ytdl-sub | ||
premiered: 2020-08-08 | ||
title: Mock Entry 20-2 | ||
Mock Entry 20-3.info.json | ||
Mock Entry 20-3.jpg | ||
Mock Entry 20-3.mp4 | ||
Video Tags: | ||
album: Music Videos | ||
artist: JMC | ||
genre: ytdl-sub | ||
premiered: 2020-08-07 | ||
title: Mock Entry 20-3 | ||
year: 2020 | ||
Mock Entry 20-3.nfo | ||
NFO tags: | ||
musicvideo: | ||
album: Music Videos | ||
artist: JMC | ||
genre: ytdl-sub | ||
premiered: 2020-08-07 | ||
title: Mock Entry 20-3 | ||
Mock Entry 21-1.info.json | ||
Mock Entry 21-1.jpg | ||
Mock Entry 21-1.mp4 | ||
Video Tags: | ||
album: Music Videos | ||
artist: JMC | ||
genre: ytdl-sub | ||
premiered: 2021-08-08 | ||
title: Mock Entry 21-1 | ||
year: 2021 | ||
Mock Entry 21-1.nfo | ||
NFO tags: | ||
musicvideo: | ||
album: Music Videos | ||
artist: JMC | ||
genre: ytdl-sub | ||
premiered: 2021-08-08 | ||
title: Mock Entry 21-1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters