mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-20 06:56:18 -05:00
Testing bad downloader param.
This commit is contained in:
parent
e3c57ef674
commit
d56c8fde24
3 changed files with 14 additions and 2 deletions
|
|
@ -246,4 +246,4 @@ def download_channel(link: str):
|
|||
channel = get_channel(link=link, return_dict=False)
|
||||
# TODO do not download the channel if it does not already have Download record.
|
||||
with get_db_session(commit=True) as session:
|
||||
download_manager.create_download(channel.url, session)
|
||||
download_manager.create_download(channel.url, session, downloader='video_channel')
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ from copy import copy
|
|||
from datetime import datetime
|
||||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
from yt_dlp.utils import UnsupportedError
|
||||
|
||||
from modules.videos.channel.lib import spread_channel_downloads
|
||||
|
|
@ -13,6 +14,7 @@ from modules.videos.test.common import create_channel_structure
|
|||
from wrolpi.dates import local_timezone
|
||||
from wrolpi.db import get_db_session, get_db_context
|
||||
from wrolpi.downloader import DownloadManager, Download, DownloadFrequency
|
||||
from wrolpi.errors import InvalidDownload
|
||||
from wrolpi.test.common import wrap_test_db, TestAPI
|
||||
from wrolpi.test.test_downloader import HTTPDownloader
|
||||
|
||||
|
|
@ -434,3 +436,11 @@ def test_channel_downloader_hidden(video_download_manager):
|
|||
"""
|
||||
downloaders = video_download_manager.list_downloaders()
|
||||
assert downloaders == [(dict(name='video', pretty_name='Videos')), ]
|
||||
|
||||
|
||||
def test_bad_downloader(test_session, video_download_manager):
|
||||
"""
|
||||
Attempting to use an unknown downloader should raise an error.
|
||||
"""
|
||||
with pytest.raises(InvalidDownload):
|
||||
video_download_manager.create_download('https://example.com', test_session, 'bad downloader')
|
||||
|
|
|
|||
|
|
@ -278,6 +278,9 @@ class DownloadManager:
|
|||
|
||||
downloads = []
|
||||
forced_downloader = self.get_downloader_by_name(downloader) if downloader else None
|
||||
if downloader and not forced_downloader:
|
||||
# Could not find the downloader
|
||||
raise InvalidDownload(f'Unknown downloader {downloader}')
|
||||
|
||||
with session.transaction:
|
||||
for url in urls:
|
||||
|
|
@ -324,7 +327,6 @@ class DownloadManager:
|
|||
url = download.url
|
||||
|
||||
downloader = self.get_downloader_by_name(download.downloader)
|
||||
info = len(download.info_json) if download.info_json else None
|
||||
if not downloader:
|
||||
downloader, info_json = self.get_downloader(download.url)
|
||||
download.downloader = downloader.name
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue