Tests beginning for playlist.plex.server
Signed-off-by: Cliff Hill <xlorep@darkhelm.org>
This commit is contained in:
28
tests/plex/test_server.py
Normal file
28
tests/plex/test_server.py
Normal file
@@ -0,0 +1,28 @@
|
||||
"""Tests for the playlist.plex.server module."""
|
||||
import pytest # type: ignore [import]
|
||||
|
||||
from playlist.plex import server # type: ignore [import]
|
||||
|
||||
|
||||
def test_calc_delay(mocker: pytest.fixture) -> None:
|
||||
"""Test the calc_delay function."""
|
||||
mock_settings = mocker.patch("playlist.plex.server.settings")
|
||||
mock_const = mocker.patch("playlist.plex.server.const")
|
||||
times = [100, 100, 100]
|
||||
weights = [100, 100, 100]
|
||||
mock_const.MAX_PROCESSES = 1
|
||||
server.calc_delay(times, weights)
|
||||
mock_s = mock_settings.modify.return_value.__enter__.return_value
|
||||
result = mock_s.download.process_delay
|
||||
assert result == 100
|
||||
|
||||
|
||||
def test_calc_duration(mocker: pytest.fixture) -> None:
|
||||
"""Test the calc_duration function."""
|
||||
mock_settings = mocker.patch("playlist.plex.server.settings")
|
||||
durations = [100, 100, 100]
|
||||
mock_s = mock_settings.modify.return_value.__enter__.return_value
|
||||
mock_s.playlist.playtime.total_seconds.return_value = 300
|
||||
server.calc_duration(durations)
|
||||
result = mock_s.playlist.max_tracks
|
||||
assert result == 2
|
||||
Reference in New Issue
Block a user