fix unit tests
This commit is contained in:
parent
b9a9ba2950
commit
b17d773248
6 changed files with 68 additions and 32 deletions
|
|
@ -13,6 +13,7 @@ presets:
|
|||
file_name: "[{album_year}] {sanitized_album}/{track_number_padded} - {sanitized_title}.{ext}"
|
||||
convert_thumbnail: "jpeg"
|
||||
thumbnail_name: "[{album_year}] {sanitized_album}/folder.jpeg"
|
||||
maintain_download_archive: True
|
||||
metadata_options:
|
||||
id3:
|
||||
id3_version: "2.4"
|
||||
|
|
@ -65,7 +66,7 @@ presets:
|
|||
episode: "{upload_month}{upload_day_padded}"
|
||||
plot: "{description}"
|
||||
year: "{upload_year}"
|
||||
aired: "{upload_year}-{upload_month_padded}-{upload_day_padded}"
|
||||
aired: "{upload_date_standardized}"
|
||||
output_directory_nfo:
|
||||
nfo_name: "tvshow.nfo"
|
||||
nfo_root: "tvshow"
|
||||
|
|
|
|||
|
|
@ -18,15 +18,15 @@
|
|||
# artist: "DeLorra"
|
||||
# genre: "Synthwave / Electronic"
|
||||
#
|
||||
#bl00dwave:
|
||||
# preset: "soundcloud_with_id3_tags"
|
||||
# soundcloud:
|
||||
# username: bl00dwave
|
||||
# output_options:
|
||||
# output_directory: "/tmp/bl00dwave"
|
||||
# overrides:
|
||||
# artist: "bl00dwave"
|
||||
# genre: "Synthwave / Electronic"
|
||||
bl00dwave:
|
||||
preset: "soundcloud_with_id3_tags"
|
||||
soundcloud:
|
||||
username: bl00dwave
|
||||
output_options:
|
||||
output_directory: "/tmp/bl00dwave"
|
||||
overrides:
|
||||
artist: "bl00dwave"
|
||||
genre: "Synthwave / Electronic"
|
||||
#
|
||||
#tom_petty:
|
||||
# preset: "music_videos"
|
||||
|
|
@ -58,15 +58,15 @@
|
|||
# overrides:
|
||||
# artist: "The Gogos"
|
||||
|
||||
recent_channel_test:
|
||||
preset: "yt_channel"
|
||||
ytdl_options:
|
||||
break_on_reject: True
|
||||
youtube:
|
||||
download_strategy: "channel"
|
||||
channel_id: "UCRcCVDu_4oARsAKFkKYydAQ"
|
||||
after: today-8months
|
||||
output_options:
|
||||
output_directory: "/tmp/dunkey"
|
||||
overrides:
|
||||
tv_show_name: "Youtube: Dunkey"
|
||||
#recent_channel_test:
|
||||
# preset: "yt_channel"
|
||||
# ytdl_options:
|
||||
# break_on_reject: True
|
||||
# youtube:
|
||||
# download_strategy: "channel"
|
||||
# channel_id: "UCRcCVDu_4oARsAKFkKYydAQ"
|
||||
# after: today-2days
|
||||
# output_options:
|
||||
# output_directory: "/tmp/dunkey"
|
||||
# overrides:
|
||||
# tv_show_name: "Youtube: Dunkey"
|
||||
|
|
@ -4,6 +4,12 @@ from ytdl_subscribe.entries.entry import Entry
|
|||
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
|
||||
def uid():
|
||||
return "abc123"
|
||||
|
|
@ -19,14 +25,29 @@ def title():
|
|||
return "entry title"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def description():
|
||||
return "a description"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def upload_year():
|
||||
return 2021
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def upload_date(upload_year):
|
||||
return f"{upload_year}-01-06"
|
||||
def upload_month():
|
||||
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
|
||||
|
|
@ -51,7 +72,17 @@ def download_file_name(uid, ext):
|
|||
|
||||
@pytest.fixture
|
||||
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 {
|
||||
"uid": uid,
|
||||
|
|
@ -59,15 +90,21 @@ def mock_entry_to_dict(
|
|||
"sanitized_title": title,
|
||||
"ext": ext,
|
||||
"upload_date": upload_date,
|
||||
"upload_date_standardized": f"{upload_year}-{_pad(upload_month)}-{_pad(upload_day)}",
|
||||
"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_ext": thumbnail_ext,
|
||||
"extractor": extractor,
|
||||
"description": description,
|
||||
}
|
||||
|
||||
|
||||
@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 {
|
||||
"id": uid,
|
||||
"extractor": extractor,
|
||||
|
|
@ -75,6 +112,7 @@ def mock_entry_kwargs(uid, title, ext, upload_date, thumbnail):
|
|||
"ext": ext,
|
||||
"upload_date": upload_date,
|
||||
"thumbnail": thumbnail,
|
||||
"description": description,
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,9 +3,7 @@ import tempfile
|
|||
import pytest
|
||||
|
||||
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 ValidationException
|
||||
|
||||
|
||||
class TestEntry(object):
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ class PlaylistMetadata:
|
|||
playlist_extractor: str
|
||||
|
||||
|
||||
# TODO: strip things out of entry into BaseEntry
|
||||
class BaseEntry(ABC):
|
||||
def __init__(self, **kwargs):
|
||||
"""
|
||||
|
|
@ -131,7 +130,7 @@ class Entry(BaseEntry):
|
|||
return int(self.upload_day_padded.lstrip("0"))
|
||||
|
||||
@property
|
||||
def standardized_upload_date(self) -> str:
|
||||
def upload_date_standardized(self) -> str:
|
||||
"""
|
||||
:return: upload date as YYYY-MM-DD
|
||||
"""
|
||||
|
|
@ -179,12 +178,12 @@ class Entry(BaseEntry):
|
|||
"description": self.description,
|
||||
"ext": self.ext,
|
||||
"upload_date": self.upload_date,
|
||||
"upload_date_standardized": self.upload_date_standardized,
|
||||
"upload_year": self.upload_year,
|
||||
"upload_month": self.upload_month,
|
||||
"upload_month_padded": self.upload_month_padded,
|
||||
"upload_day": self.upload_day,
|
||||
"upload_day_padded": self.upload_day_padded,
|
||||
"standardized_upload_date": self.standardized_upload_date,
|
||||
"thumbnail": self.thumbnail,
|
||||
"thumbnail_ext": self.thumbnail_ext,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ class DownloadMapping:
|
|||
@classmethod
|
||||
def from_entry(cls, entry: Entry) -> "DownloadMapping":
|
||||
return DownloadMapping(
|
||||
upload_date=entry.standardized_upload_date,
|
||||
upload_date=entry.upload_date_standardized,
|
||||
extractor=entry.extractor,
|
||||
file_names=set(),
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue