Testing bad downloader param.

This commit is contained in:
Roland 2021-12-30 18:36:02 -07:00
parent e3c57ef674
commit d56c8fde24
No known key found for this signature in database
GPG key ID: 9D6DBD3ACF11AB93
3 changed files with 14 additions and 2 deletions

View file

@ -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')

View file

@ -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')