This commit is contained in:
Jesse Bannon 2025-08-19 00:23:43 -07:00
parent 551cba2beb
commit 2b9937f4dd
2 changed files with 52 additions and 50 deletions

View file

@ -1,7 +1,8 @@
import contextlib
import os
from pathlib import Path
from typing import Callable, Any
from typing import Any
from typing import Callable
from typing import Dict
from typing import List
from typing import Optional
@ -55,7 +56,7 @@ def mock_entry_dict_factory(mock_downloaded_file_path) -> Callable:
mock_download_to_working_dir: bool = True,
is_extracted_audio: bool = False,
release_date: Optional[str] = None,
mock_entry_kwargs: Optional[Dict[str, Any]] = None
mock_entry_kwargs: Optional[Dict[str, Any]] = None,
) -> Dict:
entry_dict = {
v.uid.metadata_key: uid,
@ -141,7 +142,9 @@ def mock_download_collection_thumbnail(mock_downloaded_file_path):
@pytest.fixture
def mock_download_collection_entries(
mock_download_collection_thumbnail, mock_entry_dict_factory: Callable, working_directory: str,
mock_download_collection_thumbnail,
mock_entry_dict_factory: Callable,
working_directory: str,
):
@contextlib.contextmanager
def _mock_download_collection_entries_factory(

View file

@ -179,6 +179,7 @@ class TestThrottleProtectionPlugin:
assert transaction_log.is_empty
class TestResolutionAssert:
@pytest.mark.parametrize(
"disable_value",
@ -200,13 +201,11 @@ class TestResolutionAssert:
):
throttle_subscription_dict["overrides"]["enable_resolution_assert"] = disable_value
with (
assert_logs(
with assert_logs(
logger=script_print_logger,
expected_message="Resolution assert is disabled. Use at your own risk!",
log_level="info",
expected_occurrences=1,
)
):
_ = Subscription.from_dict(
config=config,
@ -229,10 +228,9 @@ class TestResolutionAssert:
output_directory,
mock_download_collection_entries,
width,
height
height,
):
with (
assert_logs(
with assert_logs(
logger=script_print_logger,
expected_message=(
"Resolution assert is enabled, will fail on low-quality video downloads and presume throttle. "
@ -240,7 +238,6 @@ class TestResolutionAssert:
),
log_level="info",
expected_occurrences=1,
)
):
subscription = Subscription.from_dict(
config=config,
@ -250,10 +247,11 @@ class TestResolutionAssert:
with (
mock_download_collection_entries(
is_youtube_channel=False, num_urls=1, is_extracted_audio=False, is_dry_run=True, mock_entry_kwargs={
"height": height,
"width": width
}
is_youtube_channel=False,
num_urls=1,
is_extracted_audio=False,
is_dry_run=True,
mock_entry_kwargs={"height": height, "width": width},
),
):
_ = subscription.download(dry_run=True)
@ -279,10 +277,11 @@ class TestResolutionAssert:
with (
mock_download_collection_entries(
is_youtube_channel=False, num_urls=1, is_extracted_audio=False, is_dry_run=True, mock_entry_kwargs={
"height": 360,
"width": 640
}
is_youtube_channel=False,
num_urls=1,
is_extracted_audio=False,
is_dry_run=True,
mock_entry_kwargs={"height": 360, "width": 640},
),
pytest.raises(UserThrownRuntimeError, match=re.escape(expected_message)),
):