lots of changes
This commit is contained in:
parent
7c20f3fc57
commit
63dee675b0
3 changed files with 7 additions and 59 deletions
|
|
@ -1,11 +1,9 @@
|
||||||
from pathlib import Path
|
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
|
|
||||||
import pytest
|
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 mergedeep import mergedeep
|
|
||||||
|
|
||||||
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.downloaders.ytdlp import YTDLP
|
||||||
|
|
@ -98,50 +96,6 @@ class TestPlaylist:
|
||||||
files exist and have the expected md5 file hashes.
|
files exist and have the expected md5 file hashes.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def _ensure_subscription_migrates(
|
|
||||||
cls,
|
|
||||||
config: ConfigFile,
|
|
||||||
subscription_name: str,
|
|
||||||
subscription_dict: Dict,
|
|
||||||
output_directory: Path,
|
|
||||||
):
|
|
||||||
# Ensure download archive migrates
|
|
||||||
mergedeep.merge(
|
|
||||||
subscription_dict,
|
|
||||||
{
|
|
||||||
"output_options": {
|
|
||||||
"migrated_download_archive_name": ".ytdl-sub-{tv_show_name_sanitized}-download-archive.json"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
)
|
|
||||||
migrated_subscription = Subscription.from_dict(
|
|
||||||
config=config,
|
|
||||||
preset_name=subscription_name,
|
|
||||||
preset_dict=subscription_dict,
|
|
||||||
)
|
|
||||||
transaction_log = migrated_subscription.download()
|
|
||||||
|
|
||||||
assert_transaction_log_matches(
|
|
||||||
output_directory=output_directory,
|
|
||||||
transaction_log=transaction_log,
|
|
||||||
transaction_log_summary_file_name="youtube/test_playlist_archive_migrated.txt",
|
|
||||||
)
|
|
||||||
assert_expected_downloads(
|
|
||||||
output_directory=output_directory,
|
|
||||||
dry_run=False,
|
|
||||||
expected_download_summary_file_name="youtube/test_playlist_archive_migrated.json",
|
|
||||||
)
|
|
||||||
|
|
||||||
# Ensure no changes after migration
|
|
||||||
transaction_log = migrated_subscription.download()
|
|
||||||
assert transaction_log.is_empty
|
|
||||||
assert_expected_downloads(
|
|
||||||
output_directory=output_directory,
|
|
||||||
dry_run=False,
|
|
||||||
expected_download_summary_file_name="youtube/test_playlist_archive_migrated.json",
|
|
||||||
)
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("dry_run", [True, False])
|
@pytest.mark.parametrize("dry_run", [True, False])
|
||||||
def test_playlist_download(
|
def test_playlist_download(
|
||||||
self,
|
self,
|
||||||
|
|
@ -184,13 +138,6 @@ class TestPlaylist:
|
||||||
expected_download_summary_file_name="youtube/test_playlist.json",
|
expected_download_summary_file_name="youtube/test_playlist.json",
|
||||||
)
|
)
|
||||||
|
|
||||||
self._ensure_subscription_migrates(
|
|
||||||
config=default_config,
|
|
||||||
subscription_name="music_video_playlist_test",
|
|
||||||
subscription_dict=playlist_preset_dict,
|
|
||||||
output_directory=output_directory,
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_tv_show_by_date_downloads_bilateral(
|
def test_tv_show_by_date_downloads_bilateral(
|
||||||
self,
|
self,
|
||||||
tv_show_by_date_bilateral_dict: Dict,
|
tv_show_by_date_bilateral_dict: Dict,
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,9 @@ from typing import Dict
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from mergedeep import mergedeep
|
|
||||||
|
|
||||||
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 mergedeep import mergedeep
|
||||||
|
|
||||||
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.downloaders.ytdlp import YTDLP
|
||||||
|
|
@ -113,7 +112,9 @@ class TestOutputOptions:
|
||||||
expected_download_summary_file_name="plugins/output_options/pre_migration.json",
|
expected_download_summary_file_name="plugins/output_options/pre_migration.json",
|
||||||
)
|
)
|
||||||
|
|
||||||
output_options_subscription_dict["output_options"]["migrated_download_archive_name"] = ".ytdl-sub-{tv_show_name_sanitized}-migrated-download-archive.json"
|
output_options_subscription_dict["output_options"][
|
||||||
|
"migrated_download_archive_name"
|
||||||
|
] = ".ytdl-sub-{tv_show_name_sanitized}-migrated-download-archive.json"
|
||||||
subscription = Subscription.from_dict(
|
subscription = Subscription.from_dict(
|
||||||
config=config,
|
config=config,
|
||||||
preset_name=subscription_name,
|
preset_name=subscription_name,
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import os
|
||||||
import shutil
|
import shutil
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
REGENERATE_FIXTURES: bool = True
|
REGENERATE_FIXTURES: bool = False
|
||||||
|
|
||||||
RESOURCE_PATH: Path = Path("tests") / "resources"
|
RESOURCE_PATH: Path = Path("tests") / "resources"
|
||||||
_FILE_FIXTURE_PATH: Path = RESOURCE_PATH / "file_fixtures"
|
_FILE_FIXTURE_PATH: Path = RESOURCE_PATH / "file_fixtures"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue