From baf655b88b45de857e12b9a2c302ccde6bc9aa8c Mon Sep 17 00:00:00 2001 From: Hellowlol Date: Sun, 29 Oct 2017 00:40:35 +0200 Subject: [PATCH] add split, unmatch, stop, installupdate --- plexapi/__init__.py | 4 +++- tests/test_server.py | 11 ++++++++--- tests/test_video.py | 13 +++++++++++++ 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/plexapi/__init__.py b/plexapi/__init__.py index fd517488..cd49c7fa 100644 --- a/plexapi/__init__.py +++ b/plexapi/__init__.py @@ -35,10 +35,12 @@ logfile = CONFIG.get('log.path') logformat = CONFIG.get('log.format', '%(asctime)s %(module)12s:%(lineno)-4s %(levelname)-9s %(message)s') loglevel = CONFIG.get('log.level', 'INFO').upper() loghandler = logging.NullHandler() -if logfile: + +if logfile: # pragma: no cover logbackups = CONFIG.get('log.backup_count', 3, int) logbytes = CONFIG.get('log.rotate_bytes', 512000, int) loghandler = RotatingFileHandler(os.path.expanduser(logfile), 'a', logbytes, logbackups) + loghandler.setFormatter(logging.Formatter(logformat)) log.addHandler(loghandler) log.setLevel(loglevel) diff --git a/tests/test_server.py b/tests/test_server.py index 3e51616f..5103e0c8 100644 --- a/tests/test_server.py +++ b/tests/test_server.py @@ -165,9 +165,14 @@ def test_server_sessions(plex): def test_server_isLatest(plex, mocker): - # I really need to update the testservers pms.. TODO - with mocker.patch('plexapi.server.PlexServer.isLatest', return_value=True): - assert plex.isLatest() is True + plex.isLatest() + + +def test_server_installUpdate(plex, mocker): + m = mocker.MagicMock(release='aa') + mocker.patch('plexapi.server.PlexServer.check_for_update', return_value=m) + with utils.callable_http_patch(): + plex.installUpdate() def test_server_check_for_update(plex, mocker): diff --git a/tests/test_video.py b/tests/test_video.py index afae4447..ae6673e6 100644 --- a/tests/test_video.py +++ b/tests/test_video.py @@ -271,6 +271,19 @@ def test_video_Show(show): assert show.title == 'Game of Thrones' +def test_video_Episode_split(episode, patched_http_call): + episode.split() + + +def test_video_Episode_unmatch(episode, patched_http_call): + episode.unmatch() + + +def test_video_Episode_stop(episode, mocker, patched_http_call): + mocker.patch.object(episode, 'session', return_value=list(mocker.MagicMock(id='hello'))) + episode.stop(reason="It's past bedtime!") + + def test_video_Show_attrs(show): assert utils.is_datetime(show.addedAt) assert utils.is_metadata(show.art, contains='/art/')