[BACKEND] More tests around passed-in ytdl-options
This commit is contained in:
parent
c1431c8d55
commit
f820a61ec8
2 changed files with 40 additions and 2 deletions
|
|
@ -117,7 +117,8 @@ def assert_logs(
|
||||||
yield
|
yield
|
||||||
|
|
||||||
for call_args in patched_debug.call_args_list:
|
for call_args in patched_debug.call_args_list:
|
||||||
occurrences += int(expected_message in call_args.args[0])
|
full_print = call_args.args[0] % call_args.args[1:]
|
||||||
|
occurrences += int(expected_message in full_print)
|
||||||
|
|
||||||
if expected_occurrences is not None:
|
if expected_occurrences is not None:
|
||||||
assert (
|
assert (
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,14 @@ from typing import Any
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from conftest import get_match_filters
|
import yt_dlp
|
||||||
|
from conftest import assert_logs
|
||||||
|
|
||||||
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.subscriptions.subscription import Subscription
|
from ytdl_sub.subscriptions.subscription import Subscription
|
||||||
from ytdl_sub.utils.exceptions import ValidationException
|
from ytdl_sub.utils.exceptions import ValidationException
|
||||||
|
from ytdl_sub.utils.ffmpeg import FFMPEG
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
|
|
@ -19,6 +22,40 @@ def preset_dict(output_directory) -> Dict[str, Any]:
|
||||||
|
|
||||||
|
|
||||||
class TestYtdlOptions:
|
class TestYtdlOptions:
|
||||||
|
|
||||||
|
def test_ytdl_options_are_strings(
|
||||||
|
self,
|
||||||
|
default_config: ConfigFile,
|
||||||
|
preset_dict: Dict[str, Any],
|
||||||
|
working_directory,
|
||||||
|
):
|
||||||
|
expected_ytdl_options = {
|
||||||
|
"ignoreerrors": True,
|
||||||
|
"outtmpl": f"{working_directory}/test_ytdl_options/%(id)S.%(ext)s",
|
||||||
|
"writethumbnail": False,
|
||||||
|
"ffmpeg_location": FFMPEG.ffmpeg_path(),
|
||||||
|
"match_filter": yt_dlp.utils.match_filter_func(
|
||||||
|
["!is_live & !is_upcoming & !post_live"], []
|
||||||
|
),
|
||||||
|
"skip_download": True,
|
||||||
|
"writeinfojson": True,
|
||||||
|
"extract_flat": "discard",
|
||||||
|
}
|
||||||
|
|
||||||
|
with (
|
||||||
|
assert_logs(
|
||||||
|
logger=YTDLP.logger,
|
||||||
|
expected_message=f"ytdl_options: {str(expected_ytdl_options)}",
|
||||||
|
log_level="debug",
|
||||||
|
expected_occurrences=1,
|
||||||
|
),
|
||||||
|
):
|
||||||
|
_ = Subscription.from_dict(
|
||||||
|
config=default_config,
|
||||||
|
preset_name="test_ytdl_options",
|
||||||
|
preset_dict=preset_dict,
|
||||||
|
).download(dry_run=True)
|
||||||
|
|
||||||
def test_cookiefile_does_not_exist(
|
def test_cookiefile_does_not_exist(
|
||||||
self,
|
self,
|
||||||
default_config: ConfigFile,
|
default_config: ConfigFile,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue