fix unit tests

This commit is contained in:
jbannon 2022-04-12 04:07:31 +00:00
parent b9a9ba2950
commit b17d773248
6 changed files with 68 additions and 32 deletions

View file

@ -13,6 +13,7 @@ presets:
file_name: "[{album_year}] {sanitized_album}/{track_number_padded} - {sanitized_title}.{ext}" file_name: "[{album_year}] {sanitized_album}/{track_number_padded} - {sanitized_title}.{ext}"
convert_thumbnail: "jpeg" convert_thumbnail: "jpeg"
thumbnail_name: "[{album_year}] {sanitized_album}/folder.jpeg" thumbnail_name: "[{album_year}] {sanitized_album}/folder.jpeg"
maintain_download_archive: True
metadata_options: metadata_options:
id3: id3:
id3_version: "2.4" id3_version: "2.4"
@ -65,7 +66,7 @@ presets:
episode: "{upload_month}{upload_day_padded}" episode: "{upload_month}{upload_day_padded}"
plot: "{description}" plot: "{description}"
year: "{upload_year}" year: "{upload_year}"
aired: "{upload_year}-{upload_month_padded}-{upload_day_padded}" aired: "{upload_date_standardized}"
output_directory_nfo: output_directory_nfo:
nfo_name: "tvshow.nfo" nfo_name: "tvshow.nfo"
nfo_root: "tvshow" nfo_root: "tvshow"

View file

@ -18,15 +18,15 @@
# artist: "DeLorra" # artist: "DeLorra"
# genre: "Synthwave / Electronic" # genre: "Synthwave / Electronic"
# #
#bl00dwave: bl00dwave:
# preset: "soundcloud_with_id3_tags" preset: "soundcloud_with_id3_tags"
# soundcloud: soundcloud:
# username: bl00dwave username: bl00dwave
# output_options: output_options:
# output_directory: "/tmp/bl00dwave" output_directory: "/tmp/bl00dwave"
# overrides: overrides:
# artist: "bl00dwave" artist: "bl00dwave"
# genre: "Synthwave / Electronic" genre: "Synthwave / Electronic"
# #
#tom_petty: #tom_petty:
# preset: "music_videos" # preset: "music_videos"
@ -58,15 +58,15 @@
# overrides: # overrides:
# artist: "The Gogos" # artist: "The Gogos"
recent_channel_test: #recent_channel_test:
preset: "yt_channel" # preset: "yt_channel"
ytdl_options: # ytdl_options:
break_on_reject: True # break_on_reject: True
youtube: # youtube:
download_strategy: "channel" # download_strategy: "channel"
channel_id: "UCRcCVDu_4oARsAKFkKYydAQ" # channel_id: "UCRcCVDu_4oARsAKFkKYydAQ"
after: today-8months # after: today-2days
output_options: # output_options:
output_directory: "/tmp/dunkey" # output_directory: "/tmp/dunkey"
overrides: # overrides:
tv_show_name: "Youtube: Dunkey" # tv_show_name: "Youtube: Dunkey"

View file

@ -4,6 +4,12 @@ from ytdl_subscribe.entries.entry import Entry
from ytdl_subscribe.validators.base.string_formatter_validators import StringFormatterValidator from ytdl_subscribe.validators.base.string_formatter_validators import StringFormatterValidator
def _pad(num):
if num < 10:
return f"0{num}"
return str(num)
@pytest.fixture @pytest.fixture
def uid(): def uid():
return "abc123" return "abc123"
@ -19,14 +25,29 @@ def title():
return "entry title" return "entry title"
@pytest.fixture
def description():
return "a description"
@pytest.fixture @pytest.fixture
def upload_year(): def upload_year():
return 2021 return 2021
@pytest.fixture @pytest.fixture
def upload_date(upload_year): def upload_month():
return f"{upload_year}-01-06" return 1
@pytest.fixture
def upload_day():
return 6
@pytest.fixture
def upload_date(upload_year, upload_month, upload_day):
return f"{upload_year}{_pad(upload_month)}{_pad(upload_day)}"
@pytest.fixture @pytest.fixture
@ -51,7 +72,17 @@ def download_file_name(uid, ext):
@pytest.fixture @pytest.fixture
def mock_entry_to_dict( def mock_entry_to_dict(
uid, title, ext, upload_date, upload_year, thumbnail, thumbnail_ext, extractor uid,
title,
ext,
upload_date,
upload_year,
thumbnail,
thumbnail_ext,
extractor,
description,
upload_month,
upload_day,
): ):
return { return {
"uid": uid, "uid": uid,
@ -59,15 +90,21 @@ def mock_entry_to_dict(
"sanitized_title": title, "sanitized_title": title,
"ext": ext, "ext": ext,
"upload_date": upload_date, "upload_date": upload_date,
"upload_date_standardized": f"{upload_year}-{_pad(upload_month)}-{_pad(upload_day)}",
"upload_year": upload_year, "upload_year": upload_year,
"upload_month": upload_month,
"upload_month_padded": _pad(upload_month),
"upload_day": upload_day,
"upload_day_padded": _pad(upload_day),
"thumbnail": thumbnail, "thumbnail": thumbnail,
"thumbnail_ext": thumbnail_ext, "thumbnail_ext": thumbnail_ext,
"extractor": extractor, "extractor": extractor,
"description": description,
} }
@pytest.fixture @pytest.fixture
def mock_entry_kwargs(uid, title, ext, upload_date, thumbnail): def mock_entry_kwargs(uid, title, ext, upload_date, thumbnail, extractor, description):
return { return {
"id": uid, "id": uid,
"extractor": extractor, "extractor": extractor,
@ -75,6 +112,7 @@ def mock_entry_kwargs(uid, title, ext, upload_date, thumbnail):
"ext": ext, "ext": ext,
"upload_date": upload_date, "upload_date": upload_date,
"thumbnail": thumbnail, "thumbnail": thumbnail,
"description": description,
} }

View file

@ -3,9 +3,7 @@ import tempfile
import pytest import pytest
from ytdl_subscribe.validators.base.string_formatter_validators import StringFormatterValidator from ytdl_subscribe.validators.base.string_formatter_validators import StringFormatterValidator
from ytdl_subscribe.validators.config.overrides.overrides_validator import OverridesValidator
from ytdl_subscribe.validators.exceptions import StringFormattingException from ytdl_subscribe.validators.exceptions import StringFormattingException
from ytdl_subscribe.validators.exceptions import ValidationException
class TestEntry(object): class TestEntry(object):

View file

@ -18,7 +18,6 @@ class PlaylistMetadata:
playlist_extractor: str playlist_extractor: str
# TODO: strip things out of entry into BaseEntry
class BaseEntry(ABC): class BaseEntry(ABC):
def __init__(self, **kwargs): def __init__(self, **kwargs):
""" """
@ -131,7 +130,7 @@ class Entry(BaseEntry):
return int(self.upload_day_padded.lstrip("0")) return int(self.upload_day_padded.lstrip("0"))
@property @property
def standardized_upload_date(self) -> str: def upload_date_standardized(self) -> str:
""" """
:return: upload date as YYYY-MM-DD :return: upload date as YYYY-MM-DD
""" """
@ -179,12 +178,12 @@ class Entry(BaseEntry):
"description": self.description, "description": self.description,
"ext": self.ext, "ext": self.ext,
"upload_date": self.upload_date, "upload_date": self.upload_date,
"upload_date_standardized": self.upload_date_standardized,
"upload_year": self.upload_year, "upload_year": self.upload_year,
"upload_month": self.upload_month, "upload_month": self.upload_month,
"upload_month_padded": self.upload_month_padded, "upload_month_padded": self.upload_month_padded,
"upload_day": self.upload_day, "upload_day": self.upload_day,
"upload_day_padded": self.upload_day_padded, "upload_day_padded": self.upload_day_padded,
"standardized_upload_date": self.standardized_upload_date,
"thumbnail": self.thumbnail, "thumbnail": self.thumbnail,
"thumbnail_ext": self.thumbnail_ext, "thumbnail_ext": self.thumbnail_ext,
}, },

View file

@ -43,7 +43,7 @@ class DownloadMapping:
@classmethod @classmethod
def from_entry(cls, entry: Entry) -> "DownloadMapping": def from_entry(cls, entry: Entry) -> "DownloadMapping":
return DownloadMapping( return DownloadMapping(
upload_date=entry.standardized_upload_date, upload_date=entry.upload_date_standardized,
extractor=entry.extractor, extractor=entry.extractor,
file_names=set(), file_names=set(),
) )