migration test

This commit is contained in:
Jesse Bannon 2024-10-02 21:11:28 -07:00
parent 68238e6697
commit 6410ecd8dc
5 changed files with 418 additions and 0 deletions

View file

@ -1,7 +1,10 @@
from pathlib import Path
from typing import Dict 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
@ -32,6 +35,110 @@ def output_options_subscription_dict(output_directory) -> Dict:
class TestOutputOptions: class TestOutputOptions:
@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",
)
def test_download_archive_migration(
self,
config: ConfigFile,
subscription_name: str,
output_options_subscription_dict: Dict,
output_directory: str,
mock_download_collection_entries,
):
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=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="plugins/output_options/pre_migration.txt",
)
assert_expected_downloads(
output_directory=output_directory,
dry_run=False,
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"
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=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="plugins/output_options/post_migration.txt",
)
assert_expected_downloads(
output_directory=output_directory,
dry_run=False,
expected_download_summary_file_name="plugins/output_options/post_migration.json",
)
@pytest.mark.parametrize("dry_run", [True, False]) @pytest.mark.parametrize("dry_run", [True, False])
def test_empty_info_json_and_thumb( def test_empty_info_json_and_thumb(
self, self,

View file

@ -0,0 +1,36 @@
{
".ytdl-sub-JMC-migrated-download-archive.json": "66de2cc62b86fb0cdae8a2085a35412b",
"Season 2020/s2020.e000001 - Mock Entry 20-3-thumb.jpg": "e80c508c4818454300133fe1dc1a9cd7",
"Season 2020/s2020.e000001 - Mock Entry 20-3.info.json": "INFO_JSON",
"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-thumb.jpg": "e80c508c4818454300133fe1dc1a9cd7",
"Season 2020/s2020.e000002 - Mock Entry 20-2.info.json": "INFO_JSON",
"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-thumb.jpg": "e80c508c4818454300133fe1dc1a9cd7",
"Season 2020/s2020.e000003 - Mock Entry 20-1.info.json": "INFO_JSON",
"Season 2020/s2020.e000003 - Mock Entry 20-1.mp4": "a16741d4fbf657d1de4c50493db14062",
"Season 2020/s2020.e000003 - Mock Entry 20-1.nfo": "837a61dca11bbe1874ea07cb8ef8a7c9",
"Season 2020/s2020.e000005 - Mock Entry 20-1-thumb.jpg": "e80c508c4818454300133fe1dc1a9cd7",
"Season 2020/s2020.e000005 - Mock Entry 20-1.info.json": "INFO_JSON",
"Season 2020/s2020.e000005 - Mock Entry 20-1.mp4": "619fe168c38daad37bf1e3e5e063f5c9",
"Season 2020/s2020.e000005 - Mock Entry 20-1.nfo": "1d136ac5b5debe51ea4f9bfeeb5a7b2a",
"Season 2020/s2020.e000005 - Mock Entry 20-2-thumb.jpg": "e80c508c4818454300133fe1dc1a9cd7",
"Season 2020/s2020.e000005 - Mock Entry 20-2.info.json": "INFO_JSON",
"Season 2020/s2020.e000005 - Mock Entry 20-2.mp4": "724f018060e3bb74a2cec6f9acb23663",
"Season 2020/s2020.e000005 - Mock Entry 20-2.nfo": "69a1dc9d7b2517a01cfb35c85872fac0",
"Season 2020/s2020.e000005 - Mock Entry 20-3-thumb.jpg": "e80c508c4818454300133fe1dc1a9cd7",
"Season 2020/s2020.e000005 - Mock Entry 20-3.info.json": "INFO_JSON",
"Season 2020/s2020.e000005 - Mock Entry 20-3.mp4": "b48150a340c3454824042ae283c5195a",
"Season 2020/s2020.e000005 - Mock Entry 20-3.nfo": "8cd9c68536a56bc1c877f6e6203e6bfd",
"Season 2021/s2021.e000004 - Mock Entry 21-1-thumb.jpg": "e80c508c4818454300133fe1dc1a9cd7",
"Season 2021/s2021.e000004 - Mock Entry 21-1.info.json": "INFO_JSON",
"Season 2021/s2021.e000004 - Mock Entry 21-1.mp4": "7433153952b069a5674e2a3ed529b49b",
"Season 2021/s2021.e000004 - Mock Entry 21-1.nfo": "8ee3845c514a411425b7e9198666b61c",
"Season 2021/s2021.e000005 - Mock Entry 21-1-thumb.jpg": "e80c508c4818454300133fe1dc1a9cd7",
"Season 2021/s2021.e000005 - Mock Entry 21-1.info.json": "INFO_JSON",
"Season 2021/s2021.e000005 - Mock Entry 21-1.mp4": "a6fd7345d046f697c2e71e378d328a8c",
"Season 2021/s2021.e000005 - Mock Entry 21-1.nfo": "f5ee75ac3d6f28f6bb84bbf2d4f638aa",
"tvshow.nfo": "cccca1086b41af04d8ea004b1aa250e8"
}

View file

@ -0,0 +1,20 @@
{
".ytdl-sub-subscription_test-download-archive.json": "456d8882fc5e35d74f19b386d1d9a059",
"Season 2020/s2020.e000001 - Mock Entry 20-3-thumb.jpg": "e80c508c4818454300133fe1dc1a9cd7",
"Season 2020/s2020.e000001 - Mock Entry 20-3.info.json": "INFO_JSON",
"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-thumb.jpg": "e80c508c4818454300133fe1dc1a9cd7",
"Season 2020/s2020.e000002 - Mock Entry 20-2.info.json": "INFO_JSON",
"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-thumb.jpg": "e80c508c4818454300133fe1dc1a9cd7",
"Season 2020/s2020.e000003 - Mock Entry 20-1.info.json": "INFO_JSON",
"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-thumb.jpg": "e80c508c4818454300133fe1dc1a9cd7",
"Season 2021/s2021.e000004 - Mock Entry 21-1.info.json": "INFO_JSON",
"Season 2021/s2021.e000004 - Mock Entry 21-1.mp4": "7433153952b069a5674e2a3ed529b49b",
"Season 2021/s2021.e000004 - Mock Entry 21-1.nfo": "8ee3845c514a411425b7e9198666b61c",
"tvshow.nfo": "cccca1086b41af04d8ea004b1aa250e8"
}

View file

@ -0,0 +1,127 @@
Files created:
----------------------------------------
{output_directory}
.ytdl-sub-JMC-migrated-download-archive.json
{output_directory}/Season 2020
s2020.e000005 - Mock Entry 20-1-thumb.jpg
s2020.e000005 - Mock Entry 20-1.info.json
s2020.e000005 - Mock Entry 20-1.mp4
Video Tags:
contentRating: TV-14
date: 2020-08-08
episode_id: 5
genre: ytdl-sub
show: JMC
synopsis:
https://20-1.com
The Description
title: 2020-08-08 - Mock Entry 20-1
year: 2020
s2020.e000005 - Mock Entry 20-1.nfo
NFO tags:
episodedetails:
aired: 2020-08-08
episode: 5
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
s2020.e000005 - Mock Entry 20-2-thumb.jpg
s2020.e000005 - Mock Entry 20-2.info.json
s2020.e000005 - Mock Entry 20-2.mp4
Video Tags:
contentRating: TV-14
date: 2020-08-08
episode_id: 5
genre: ytdl-sub
show: JMC
synopsis:
https://20-2.com
The Description
title: 2020-08-08 - Mock Entry 20-2
year: 2020
s2020.e000005 - Mock Entry 20-2.nfo
NFO tags:
episodedetails:
aired: 2020-08-08
episode: 5
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.e000005 - Mock Entry 20-3-thumb.jpg
s2020.e000005 - Mock Entry 20-3.info.json
s2020.e000005 - Mock Entry 20-3.mp4
Video Tags:
contentRating: TV-14
date: 2020-08-07
episode_id: 5
genre: ytdl-sub
show: JMC
synopsis:
https://20-3.com
The Description
title: 2020-08-07 - Mock Entry 20-3
year: 2020
s2020.e000005 - Mock Entry 20-3.nfo
NFO tags:
episodedetails:
aired: 2020-08-07
episode: 5
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
{output_directory}/Season 2021
s2021.e000005 - Mock Entry 21-1-thumb.jpg
s2021.e000005 - Mock Entry 21-1.info.json
s2021.e000005 - Mock Entry 21-1.mp4
Video Tags:
contentRating: TV-14
date: 2021-08-08
episode_id: 5
genre: ytdl-sub
show: JMC
synopsis:
https://21-1.com
The Description
title: 2021-08-08 - Mock Entry 21-1
year: 2021
s2021.e000005 - Mock Entry 21-1.nfo
NFO tags:
episodedetails:
aired: 2021-08-08
episode: 5
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
Files removed:
----------------------------------------
{output_directory}
.ytdl-sub-subscription_test-download-archive.json

View file

@ -0,0 +1,128 @@
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-thumb.jpg
s2020.e000001 - Mock Entry 20-3.info.json
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-thumb.jpg
s2020.e000002 - Mock Entry 20-2.info.json
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-thumb.jpg
s2020.e000003 - Mock Entry 20-1.info.json
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-thumb.jpg
s2021.e000004 - Mock Entry 21-1.info.json
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