[DEV] Test fixtures for existing channel

This commit is contained in:
Jesse Bannon 2023-11-16 22:44:46 -08:00
parent c7fce5dbdd
commit 4d093ec571
4 changed files with 149 additions and 1 deletions

View file

@ -14,6 +14,7 @@ from unittest.mock import patch
import pytest
from expected_download import _get_files_in_directory
from resources import copy_file_fixture, file_fixture_path
from ytdl_sub.config.config_file import ConfigFile
from ytdl_sub.subscriptions.subscription_download import SubscriptionDownload
@ -162,6 +163,28 @@ def preset_dict_to_subscription_yaml_generator() -> Callable:
return _preset_dict_to_subscription_yaml_generator
###################################################################################################
# Staging a mock already-existing download
@pytest.fixture
def pz_channel_mock_downloaded_with_archive_factory(output_directory: Path) -> Callable:
def _pz_channel_mock_downloaded_with_archive_factory(subscription_name: str, download_archive_file_name: str):
copy_file_fixture(fixture_name="pz_download_archive.json", output_file_path=output_directory / download_archive_file_name)
with open(file_fixture_path("pz_download_archive.json"), "r", encoding="utf-8") as archive_file:
archive_dict = json.load(archive_file)
assert isinstance(archive_dict, dict)
for uid, metadata in archive_dict.items():
assert isinstance(metadata, dict)
for filename in metadata['file_names']:
assert isinstance(filename, str)
if filename.endswith(".mp4"):
copy_file_fixture("sample_vid.mp4", output_directory / filename)
else:
copy_file_fixture("empty.txt", output_directory / filename)
return _pz_channel_mock_downloaded_with_archive_factory
###################################################################################################
# Example config fixtures

View file

@ -6,6 +6,8 @@ REGENERATE_FIXTURES: bool = False
RESOURCE_PATH: Path = Path("tests") / "resources"
_FILE_FIXTURE_PATH: Path = RESOURCE_PATH / "file_fixtures"
def file_fixture_path(fixture_name: str) -> Path:
return _FILE_FIXTURE_PATH / fixture_name
def copy_file_fixture(fixture_name: str, output_file_path: Path) -> None:
shutil.copy(_FILE_FIXTURE_PATH / fixture_name, output_file_path)
shutil.copy(file_fixture_path(fixture_name), output_file_path)

View file

View file

@ -0,0 +1,123 @@
{
"0SVukUyys10": {
"extractor": "youtube",
"file_names": [
"Season 2011/s2011.e020101 - Jesse's Minecraft Server [Trailer - Feb.1]-thumb.jpg",
"Season 2011/s2011.e020101 - Jesse's Minecraft Server [Trailer - Feb.1].info.json",
"Season 2011/s2011.e020101 - Jesse's Minecraft Server [Trailer - Feb.1].mp4",
"Season 2011/s2011.e020101 - Jesse's Minecraft Server [Trailer - Feb.1].nfo"
],
"upload_date": "2011-02-01"
},
"6sxlggREhMc": {
"extractor": "youtube",
"file_names": [
"Season 2011/s2011.e063001 - Project Zombie \uff5cFin\uff5c-thumb.jpg",
"Season 2011/s2011.e063001 - Project Zombie \uff5cFin\uff5c.info.json",
"Season 2011/s2011.e063001 - Project Zombie \uff5cFin\uff5c.mp4",
"Season 2011/s2011.e063001 - Project Zombie \uff5cFin\uff5c.nfo"
],
"upload_date": "2011-06-30"
},
"DBjFvs6HafU": {
"extractor": "youtube",
"file_names": [
"Season 2011/s2011.e032101 - Jesse's Minecraft Server [Trailer - Mar.21]-thumb.jpg",
"Season 2011/s2011.e032101 - Jesse's Minecraft Server [Trailer - Mar.21].info.json",
"Season 2011/s2011.e032101 - Jesse's Minecraft Server [Trailer - Mar.21].mp4",
"Season 2011/s2011.e032101 - Jesse's Minecraft Server [Trailer - Mar.21].nfo"
],
"upload_date": "2011-03-21"
},
"HKTNxEqsN3Q": {
"extractor": "youtube",
"file_names": [
"Season 2010/s2010.e081301 - Oblivion Mod \uff02Falcor\uff02 p.1-thumb.jpg",
"Season 2010/s2010.e081301 - Oblivion Mod \uff02Falcor\uff02 p.1.info.json",
"Season 2010/s2010.e081301 - Oblivion Mod \uff02Falcor\uff02 p.1.mp4",
"Season 2010/s2010.e081301 - Oblivion Mod \uff02Falcor\uff02 p.1.nfo"
],
"upload_date": "2010-08-13"
},
"IV9Z4wcA-z8": {
"extractor": "youtube",
"file_names": [
"Season 2010/s2010.e120201 - Oblivion Mod \uff02Falcor\uff02 p.2-thumb.jpg",
"Season 2010/s2010.e120201 - Oblivion Mod \uff02Falcor\uff02 p.2.info.json",
"Season 2010/s2010.e120201 - Oblivion Mod \uff02Falcor\uff02 p.2.mp4",
"Season 2010/s2010.e120201 - Oblivion Mod \uff02Falcor\uff02 p.2.nfo"
],
"upload_date": "2010-12-02"
},
"LN2e6idGluI": {
"extractor": "youtube",
"file_names": [
"Season 2018/s2018.e110201 - Jesse's Minecraft Server \uff5c IP mc.jesse.id-thumb.jpg",
"Season 2018/s2018.e110201 - Jesse's Minecraft Server \uff5c IP mc.jesse.id.en.srt",
"Season 2018/s2018.e110201 - Jesse's Minecraft Server \uff5c IP mc.jesse.id.info.json",
"Season 2018/s2018.e110201 - Jesse's Minecraft Server \uff5c IP mc.jesse.id.mp4",
"Season 2018/s2018.e110201 - Jesse's Minecraft Server \uff5c IP mc.jesse.id.nfo"
],
"upload_date": "2018-11-02"
},
"c_PZdc0Zi7M": {
"extractor": "youtube",
"file_names": [
"Season 2013/s2013.e071901 - Project Zombie Rewind \uff5cTrailer\uff5c-thumb.jpg",
"Season 2013/s2013.e071901 - Project Zombie Rewind \uff5cTrailer\uff5c.info.json",
"Season 2013/s2013.e071901 - Project Zombie Rewind \uff5cTrailer\uff5c.mp4",
"Season 2013/s2013.e071901 - Project Zombie Rewind \uff5cTrailer\uff5c.nfo"
],
"upload_date": "2013-07-19"
},
"hP-PL_V2wR8": {
"extractor": "youtube",
"file_names": [
"Season 2018/s2018.e102901 - Jesse's Minecraft Server \uff5c Teaser Trailer-thumb.jpg",
"Season 2018/s2018.e102901 - Jesse's Minecraft Server \uff5c Teaser Trailer.info.json",
"Season 2018/s2018.e102901 - Jesse's Minecraft Server \uff5c Teaser Trailer.mp4",
"Season 2018/s2018.e102901 - Jesse's Minecraft Server \uff5c Teaser Trailer.nfo"
],
"upload_date": "2018-10-29"
},
"hxV9b-1hjfw": {
"extractor": "youtube",
"file_names": [
"Season 2011/s2011.e052901 - Project Zombie \uff5cOfficial Trailer\uff5c (IP\uff1a mc.projectzombie.beastnode.net)-thumb.jpg",
"Season 2011/s2011.e052901 - Project Zombie \uff5cOfficial Trailer\uff5c (IP\uff1a mc.projectzombie.beastnode.net).info.json",
"Season 2011/s2011.e052901 - Project Zombie \uff5cOfficial Trailer\uff5c (IP\uff1a mc.projectzombie.beastnode.net).mp4",
"Season 2011/s2011.e052901 - Project Zombie \uff5cOfficial Trailer\uff5c (IP\uff1a mc.projectzombie.beastnode.net).nfo"
],
"upload_date": "2011-05-29"
},
"qPybBrXspds": {
"extractor": "youtube",
"file_names": [
"Season 2011/s2011.e022701 - Jesse's Minecraft Server [Trailer - Feb.27]-thumb.jpg",
"Season 2011/s2011.e022701 - Jesse's Minecraft Server [Trailer - Feb.27].info.json",
"Season 2011/s2011.e022701 - Jesse's Minecraft Server [Trailer - Feb.27].mp4",
"Season 2011/s2011.e022701 - Jesse's Minecraft Server [Trailer - Feb.27].nfo"
],
"upload_date": "2011-02-27"
},
"qbMJh2df1M4": {
"extractor": "youtube",
"file_names": [
"Season 2011/s2011.e112101 - Skyrim 'Ultra HD w\u29f8Mods' [PC]-thumb.jpg",
"Season 2011/s2011.e112101 - Skyrim 'Ultra HD w\u29f8Mods' [PC].info.json",
"Season 2011/s2011.e112101 - Skyrim 'Ultra HD w\u29f8Mods' [PC].mp4",
"Season 2011/s2011.e112101 - Skyrim 'Ultra HD w\u29f8Mods' [PC].nfo"
],
"upload_date": "2011-11-21"
},
"y5-3ovwQQ_U": {
"extractor": "youtube",
"file_names": [
"Season 2012/s2012.e012301 - Project Zombie \uff5cMap Trailer\uff5c-thumb.jpg",
"Season 2012/s2012.e012301 - Project Zombie \uff5cMap Trailer\uff5c.info.json",
"Season 2012/s2012.e012301 - Project Zombie \uff5cMap Trailer\uff5c.mp4",
"Season 2012/s2012.e012301 - Project Zombie \uff5cMap Trailer\uff5c.nfo"
],
"upload_date": "2012-01-23"
}
}