fix tests
This commit is contained in:
parent
0a2d6e274f
commit
7c940f98c6
2 changed files with 11 additions and 9 deletions
|
|
@ -265,11 +265,6 @@ def mock_download_collection_entries(
|
|||
patch.object(
|
||||
MultiUrlDownloader, "_extract_entry_info_with_retry", new=lambda _, entry: entry
|
||||
),
|
||||
# Throttle protection is included in all prebuilt presets. Mock the sleep avoid
|
||||
# actual sleeps
|
||||
patch.object(
|
||||
ThrottleProtectionPlugin, "perform_sleep", new=lambda _1, _2: None
|
||||
)
|
||||
):
|
||||
# Stub out metadata. TODO: update this if we do metadata plugins
|
||||
yield
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
from typing import Dict
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
from conftest import assert_logs
|
||||
|
||||
from ytdl_sub.plugins.throttle_protection import ThrottleProtectionPlugin
|
||||
from ytdl_sub.plugins.throttle_protection import logger as throttle_protection_logger
|
||||
from ytdl_sub.subscriptions.subscription import Subscription
|
||||
|
||||
|
|
@ -49,13 +51,18 @@ class TestThrottleProtectionPlugin:
|
|||
)
|
||||
|
||||
with (
|
||||
patch.object(
|
||||
ThrottleProtectionPlugin,
|
||||
"perform_sleep",
|
||||
new=ThrottleProtectionPlugin.perform_sleep,
|
||||
),
|
||||
mock_download_collection_entries(
|
||||
is_youtube_channel=False, num_urls=1, is_extracted_audio=False
|
||||
),
|
||||
assert_logs(
|
||||
logger=throttle_protection_logger,
|
||||
expected_message="Sleeping between downloads for %0.2f seconds",
|
||||
log_level="debug",
|
||||
log_level="info",
|
||||
expected_occurrences=4,
|
||||
),
|
||||
):
|
||||
|
|
@ -68,7 +75,7 @@ class TestThrottleProtectionPlugin:
|
|||
assert_logs(
|
||||
logger=throttle_protection_logger,
|
||||
expected_message="Sleeping between subscriptions for %0.2f seconds",
|
||||
log_level="debug",
|
||||
log_level="info",
|
||||
expected_occurrences=1,
|
||||
),
|
||||
):
|
||||
|
|
@ -92,7 +99,7 @@ class TestThrottleProtectionPlugin:
|
|||
mock_download_collection_entries,
|
||||
disable_value,
|
||||
):
|
||||
throttle_subscription_dict["throttle_protection"]["enable"] = disable_value
|
||||
throttle_subscription_dict["overrides"]["enable_throttle_protection"] = disable_value
|
||||
subscription = Subscription.from_dict(
|
||||
config=config,
|
||||
preset_name=subscription_name,
|
||||
|
|
@ -106,7 +113,7 @@ class TestThrottleProtectionPlugin:
|
|||
assert_logs(
|
||||
logger=throttle_protection_logger,
|
||||
expected_message="Sleeping between downloads for %0.2f seconds",
|
||||
log_level="debug",
|
||||
log_level="info",
|
||||
expected_occurrences=0,
|
||||
),
|
||||
):
|
||||
|
|
|
|||
Loading…
Reference in a new issue