This commit is contained in:
Jesse Bannon 2024-10-03 21:26:03 -07:00
parent 46029c7c94
commit ddcd06713a
2 changed files with 43 additions and 34 deletions

View file

@ -9,12 +9,13 @@ from ytdl_sub.utils.chapters import Chapters
@pytest.fixture @pytest.fixture
def mock_chapters_class(): def mock_chapters_class():
with patch.object(Chapters, "from_empty") as mock_chapters: with patch.object(Chapters, "from_empty") as mock_chapters:
mock_chapters.return_value = Chapters.from_string(""" mock_chapters.return_value = Chapters.from_string(
"""
"0:00 Intro\n", "0:00 Intro\n",
"00:07 Part 1\n", "00:07 Part 1\n",
"0:13 Part 2\n", "0:13 Part 2\n",
"00:19 Part 3\n", "00:19 Part 3\n",
""") """
)
yield yield

View file

@ -1,14 +1,15 @@
from typing import Dict from typing import Dict
import pytest import pytest
from mergedeep import mergedeep
from expected_download import assert_expected_downloads from expected_download import assert_expected_downloads
from expected_transaction_log import assert_transaction_log_matches from expected_transaction_log import assert_transaction_log_matches
from integration.plugins.conftest import mock_chapters_class from integration.plugins.conftest import mock_chapters_class
from mergedeep import mergedeep
from ytdl_sub.entries.entry import ytdl_sub_chapters_from_comments from ytdl_sub.entries.entry import ytdl_sub_chapters_from_comments
from ytdl_sub.subscriptions.subscription import Subscription from ytdl_sub.subscriptions.subscription import Subscription
@pytest.fixture @pytest.fixture
def chapters_base_subscription_dict(output_directory) -> Dict: def chapters_base_subscription_dict(output_directory) -> Dict:
return { return {
@ -21,42 +22,51 @@ def chapters_base_subscription_dict(output_directory) -> Dict:
}, },
} }
@pytest.fixture @pytest.fixture
def sponsorblock_disabled_dict(chapters_base_subscription_dict) -> Dict: def sponsorblock_disabled_dict(chapters_base_subscription_dict) -> Dict:
mergedeep.merge(chapters_base_subscription_dict, { mergedeep.merge(
"chapters": { chapters_base_subscription_dict,
"enable": "{enable_sponsorblock}", {
"sponsorblock_categories": [ "chapters": {
"outro", "enable": "{enable_sponsorblock}",
"selfpromo", "sponsorblock_categories": [
"preview", "outro",
"interaction", "selfpromo",
"sponsor", "preview",
"music_offtopic", "interaction",
"intro", "sponsor",
], "music_offtopic",
"remove_sponsorblock_categories": "all", "intro",
"remove_chapters_regex": [ ],
"Intro", "remove_sponsorblock_categories": "all",
"Outro", "remove_chapters_regex": [
], "Intro",
"Outro",
],
},
"overrides": {
"enable_sponsorblock": "False",
},
}, },
"overrides": { )
"enable_sponsorblock": "False",
},
})
return chapters_base_subscription_dict return chapters_base_subscription_dict
@pytest.fixture @pytest.fixture
def chapters_from_comments_subscription_dict(chapters_base_subscription_dict) -> Dict: def chapters_from_comments_subscription_dict(chapters_base_subscription_dict) -> Dict:
mergedeep.merge(chapters_base_subscription_dict, { mergedeep.merge(
"chapters": { chapters_base_subscription_dict,
"embed_chapters": True, {
"allow_chapters_from_comments": True, "chapters": {
"embed_chapters": True,
"allow_chapters_from_comments": True,
},
}, },
}) )
return chapters_base_subscription_dict return chapters_base_subscription_dict
class TestChapters: class TestChapters:
def test_chapters_disabled_respected( def test_chapters_disabled_respected(
self, self,
@ -98,9 +108,7 @@ class TestChapters:
) )
with mock_download_collection_entries( with mock_download_collection_entries(
is_youtube_channel=False, is_youtube_channel=False, num_urls=1, is_dry_run=dry_run
num_urls=1,
is_dry_run=dry_run
): ):
transaction_log = subscription.download(dry_run=dry_run) transaction_log = subscription.download(dry_run=dry_run)