lint
This commit is contained in:
parent
551cba2beb
commit
2b9937f4dd
2 changed files with 52 additions and 50 deletions
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -179,6 +179,7 @@ class TestThrottleProtectionPlugin:
|
|||
|
||||
assert transaction_log.is_empty
|
||||
|
||||
|
||||
class TestResolutionAssert:
|
||||
@pytest.mark.parametrize(
|
||||
"disable_value",
|
||||
|
|
@ -190,23 +191,21 @@ class TestResolutionAssert:
|
|||
],
|
||||
)
|
||||
def test_disabled(
|
||||
self,
|
||||
config,
|
||||
subscription_name,
|
||||
throttle_subscription_dict,
|
||||
output_directory,
|
||||
mock_download_collection_entries,
|
||||
disable_value,
|
||||
self,
|
||||
config,
|
||||
subscription_name,
|
||||
throttle_subscription_dict,
|
||||
output_directory,
|
||||
mock_download_collection_entries,
|
||||
disable_value,
|
||||
):
|
||||
throttle_subscription_dict["overrides"]["enable_resolution_assert"] = disable_value
|
||||
|
||||
with (
|
||||
assert_logs(
|
||||
logger=script_print_logger,
|
||||
expected_message="Resolution assert is disabled. Use at your own risk!",
|
||||
log_level="info",
|
||||
expected_occurrences=1,
|
||||
)
|
||||
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,
|
||||
|
|
@ -222,25 +221,23 @@ class TestResolutionAssert:
|
|||
],
|
||||
)
|
||||
def test_runs_successfully(
|
||||
self,
|
||||
config,
|
||||
subscription_name,
|
||||
throttle_subscription_dict,
|
||||
output_directory,
|
||||
mock_download_collection_entries,
|
||||
width,
|
||||
height
|
||||
self,
|
||||
config,
|
||||
subscription_name,
|
||||
throttle_subscription_dict,
|
||||
output_directory,
|
||||
mock_download_collection_entries,
|
||||
width,
|
||||
height,
|
||||
):
|
||||
with (
|
||||
assert_logs(
|
||||
logger=script_print_logger,
|
||||
expected_message=(
|
||||
"Resolution assert is enabled, will fail on low-quality video downloads and presume throttle. "
|
||||
"Disable using the override variable `enable_resolution_assert: False`"
|
||||
),
|
||||
log_level="info",
|
||||
expected_occurrences=1,
|
||||
)
|
||||
with assert_logs(
|
||||
logger=script_print_logger,
|
||||
expected_message=(
|
||||
"Resolution assert is enabled, will fail on low-quality video downloads and presume throttle. "
|
||||
"Disable using the override variable `enable_resolution_assert: False`"
|
||||
),
|
||||
log_level="info",
|
||||
expected_occurrences=1,
|
||||
):
|
||||
subscription = Subscription.from_dict(
|
||||
config=config,
|
||||
|
|
@ -250,21 +247,22 @@ 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)
|
||||
|
||||
def test_fails_low_resolution(
|
||||
self,
|
||||
config,
|
||||
subscription_name,
|
||||
throttle_subscription_dict,
|
||||
output_directory,
|
||||
mock_download_collection_entries,
|
||||
self,
|
||||
config,
|
||||
subscription_name,
|
||||
throttle_subscription_dict,
|
||||
output_directory,
|
||||
mock_download_collection_entries,
|
||||
):
|
||||
subscription = Subscription.from_dict(
|
||||
config=config,
|
||||
|
|
@ -279,11 +277,12 @@ 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)),
|
||||
):
|
||||
_ = subscription.download(dry_run=True)
|
||||
_ = subscription.download(dry_run=True)
|
||||
|
|
|
|||
Loading…
Reference in a new issue