Downloads are disabled while WROL Mode is enabled.

This commit is contained in:
Roland 2022-01-11 09:16:19 -07:00
parent f21dfa4195
commit daf795662b
No known key found for this signature in database
GPG key ID: 9D6DBD3ACF11AB93
2 changed files with 12 additions and 2 deletions

View file

@ -13,7 +13,7 @@ from sqlalchemy import Column, Integer, String, Text
from sqlalchemy.dialects.postgresql import JSONB
from sqlalchemy.orm import Session
from wrolpi.common import Base, ModelHelper, logger, iterify
from wrolpi.common import Base, ModelHelper, logger, iterify, wrol_mode_check
from wrolpi.dates import TZDateTime, now
from wrolpi.db import get_db_session, get_db_curs, get_db_context, optional_session
from wrolpi.errors import InvalidDownload, UnrecoverableDownloadError
@ -309,6 +309,7 @@ class DownloadManager:
return downloads
@wrol_mode_check
@optional_session
def _do_downloads(self, session=None):
"""

View file

@ -10,7 +10,7 @@ from wrolpi import downloader
from wrolpi.dates import local_timezone
from wrolpi.db import get_db_context
from wrolpi.downloader import Downloader, Download
from wrolpi.errors import UnrecoverableDownloadError, InvalidDownload
from wrolpi.errors import UnrecoverableDownloadError, InvalidDownload, WROLModeEnabled
from wrolpi.test.common import wrap_test_db, TestAPI
@ -307,3 +307,12 @@ def test_downloader_must_have_name():
with pytest.raises(NotImplementedError):
D()
@mock.patch('wrolpi.common.wrol_mode_enabled', lambda: True)
@pytest.mark.asyncio
async def test_download_wrol_mode(test_session, test_download_manager):
with pytest.raises(WROLModeEnabled):
test_download_manager.do_downloads_sync()
with pytest.raises(WROLModeEnabled):
await test_download_manager.do_downloads_sync()