mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-10-26 19:01:39 -04:00
The channel downloader refreshes a Channel's files before downloading, already passing send_events=False, but the parameter was never plumbed into the file worker, so every pre-download refresh notified the user. FileTask now carries send_events and handle_refresh skips the Refreshing/Refreshed events when it is False. User-requested refreshes and global refreshes still send Events. Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
39 lines
1.4 KiB
Python
39 lines
1.4 KiB
Python
"""Tests that Channel.refresh_files() only sends Events when requested.
|
|
|
|
The Channel downloader refreshes a Channel before downloading; that refresh should not
|
|
notify the user (send_events=False), while a user-requested refresh should.
|
|
"""
|
|
import pytest
|
|
|
|
from modules.videos.models import Channel
|
|
from wrolpi.common import await_background_tasks
|
|
from wrolpi.conftest import await_file_worker
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_channel_refresh_files_send_events_false(
|
|
async_client, test_session, channel_factory, video_file_factory, events_fixture):
|
|
"""Channel.refresh_files(send_events=False) must not send refresh Events."""
|
|
channel = channel_factory(name='MyChannel')
|
|
video_file_factory(channel.directory / 'video.mp4')
|
|
|
|
Channel.refresh_files(channel.id, send_events=False)
|
|
await await_file_worker()
|
|
await await_background_tasks()
|
|
|
|
events_fixture.assert_no_event('directory_refresh')
|
|
events_fixture.assert_no_event('files_refreshed')
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_channel_refresh_files_send_events_default(
|
|
async_client, test_session, channel_factory, video_file_factory, events_fixture):
|
|
"""Channel.refresh_files() sends refresh Events by default."""
|
|
channel = channel_factory(name='MyChannel')
|
|
video_file_factory(channel.directory / 'video.mp4')
|
|
|
|
Channel.refresh_files(channel.id)
|
|
await await_file_worker()
|
|
await await_background_tasks()
|
|
|
|
events_fixture.assert_has_event('directory_refresh')
|