mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-19 22:46:20 -05:00
Fixing bug where test directory was deleted. Creating dedicated Download Channel instead of using Simple Channel.
This commit is contained in:
parent
8b590d6867
commit
fded1e7492
2 changed files with 22 additions and 9 deletions
|
|
@ -12,10 +12,10 @@ def simple_channel(test_session, test_directory) -> Channel:
|
|||
"""
|
||||
channel = Channel(
|
||||
directory=test_directory,
|
||||
name='Example Channel 1',
|
||||
name='Simple Channel',
|
||||
url='https://example.com/channel1',
|
||||
download_frequency=None, # noqa
|
||||
link='examplechannel1',
|
||||
link='simplechannel',
|
||||
)
|
||||
test_session.add(channel)
|
||||
test_session.commit()
|
||||
|
|
@ -23,19 +23,31 @@ def simple_channel(test_session, test_directory) -> Channel:
|
|||
|
||||
|
||||
@pytest.fixture
|
||||
def download_channel(simple_channel) -> Channel:
|
||||
def download_channel(test_session, test_directory) -> Channel:
|
||||
"""
|
||||
Get a test Channel that has a download frequency.
|
||||
"""
|
||||
# Add a frequency to the test channel, then give it a download.
|
||||
simple_channel.download_frequency = DownloadFrequency.weekly
|
||||
channel = Channel(
|
||||
directory=test_directory,
|
||||
name='Download Channel',
|
||||
url='https://example.com/channel1',
|
||||
download_frequency=DownloadFrequency.weekly,
|
||||
link='downloadchannel',
|
||||
)
|
||||
test_session.add(channel)
|
||||
test_session.commit()
|
||||
spread_channel_downloads()
|
||||
return simple_channel
|
||||
return channel
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def simple_video(test_session, test_directory, simple_channel) -> Video:
|
||||
"""
|
||||
A Video with a video file whose channel is the Simple Channel.
|
||||
"""
|
||||
video_path = test_directory / 'simple_video.mp4'
|
||||
video_path.touch()
|
||||
video = Video(video_path=video_path, channel_id=simple_channel.id)
|
||||
test_session.add(video)
|
||||
test_session.commit()
|
||||
|
|
|
|||
|
|
@ -75,10 +75,11 @@ def test_directory() -> pathlib.Path:
|
|||
"""
|
||||
Overwrite the media directory with a temporary directory.
|
||||
"""
|
||||
tmp_dir = tempfile.TemporaryDirectory()
|
||||
tmp_path = pathlib.Path(tmp_dir.name)
|
||||
set_test_media_directory(tmp_path)
|
||||
return tmp_path
|
||||
with tempfile.TemporaryDirectory() as tmp_dir:
|
||||
tmp_path = pathlib.Path(tmp_dir)
|
||||
assert tmp_path.is_dir()
|
||||
set_test_media_directory(tmp_path)
|
||||
yield tmp_path
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue