mirror of
https://github.com/pkkid/python-plexapi
synced 2024-11-21 19:23:05 +00:00
Clean formatting
This commit is contained in:
parent
b648933963
commit
622c2490a0
12 changed files with 144 additions and 209 deletions
|
@ -1,11 +1,8 @@
|
||||||
from functools import partial
|
# -*- coding: utf-8 -*-
|
||||||
import os
|
import betamax, os, plexapi
|
||||||
import betamax
|
import pytest, requests
|
||||||
from betamax_serializers import pretty_json
|
from betamax_serializers import pretty_json
|
||||||
import pytest
|
from functools import partial
|
||||||
import requests
|
|
||||||
|
|
||||||
import plexapi
|
|
||||||
|
|
||||||
token = os.environ.get('PLEX_TOKEN')
|
token = os.environ.get('PLEX_TOKEN')
|
||||||
test_token = os.environ.get('PLEX_TEST_TOKEN')
|
test_token = os.environ.get('PLEX_TEST_TOKEN')
|
||||||
|
@ -16,25 +13,18 @@ test_password = os.environ.get('PLEX_TEST_PASSWORD')
|
||||||
@pytest.fixture(scope='session')
|
@pytest.fixture(scope='session')
|
||||||
def pms(request):
|
def pms(request):
|
||||||
from plexapi.server import PlexServer
|
from plexapi.server import PlexServer
|
||||||
|
|
||||||
sess = requests.Session()
|
sess = requests.Session()
|
||||||
|
# CASSETTE_LIBRARY_DIR = 'response/'
|
||||||
"""
|
# betamax.Betamax.register_serializer(pretty_json.PrettyJSONSerializer)
|
||||||
CASSETTE_LIBRARY_DIR = 'response/'
|
# config = betamax.Betamax.configure()
|
||||||
|
# config.define_cassette_placeholder('MASKED', token)
|
||||||
betamax.Betamax.register_serializer(pretty_json.PrettyJSONSerializer)
|
# config.define_cassette_placeholder('MASKED', test_token)
|
||||||
config = betamax.Betamax.configure()
|
# recorder = betamax.Betamax(sess, cassette_library_dir=CASSETTE_LIBRARY_DIR)
|
||||||
config.define_cassette_placeholder('MASKED', token)
|
# recorder.use_cassette('http_responses', serialize_with='prettyjson') # record='new_episodes'
|
||||||
config.define_cassette_placeholder('MASKED', test_token)
|
# recorder.start()
|
||||||
|
|
||||||
recorder = betamax.Betamax(sess, cassette_library_dir=CASSETTE_LIBRARY_DIR)
|
|
||||||
recorder.use_cassette('http_responses', serialize_with='prettyjson') # record='new_episodes'
|
|
||||||
recorder.start()
|
|
||||||
"""
|
|
||||||
url = 'http://138.68.157.5:32400'
|
url = 'http://138.68.157.5:32400'
|
||||||
assert test_token
|
assert test_token
|
||||||
assert url
|
assert url
|
||||||
|
|
||||||
pms = PlexServer(url, test_token, session=sess)
|
pms = PlexServer(url, test_token, session=sess)
|
||||||
#request.addfinalizer(recorder.stop)
|
#request.addfinalizer(recorder.stop)
|
||||||
return pms
|
return pms
|
||||||
|
@ -43,20 +33,17 @@ def pms(request):
|
||||||
@pytest.fixture()
|
@pytest.fixture()
|
||||||
def freshpms():
|
def freshpms():
|
||||||
from plexapi.server import PlexServer
|
from plexapi.server import PlexServer
|
||||||
|
|
||||||
sess = requests.Session()
|
sess = requests.Session()
|
||||||
|
|
||||||
url = 'http://138.68.157.5:32400'
|
url = 'http://138.68.157.5:32400'
|
||||||
assert test_token
|
assert test_token
|
||||||
assert url
|
assert url
|
||||||
|
|
||||||
pms = PlexServer(url, test_token, session=sess)
|
pms = PlexServer(url, test_token, session=sess)
|
||||||
return pms
|
return pms
|
||||||
|
|
||||||
|
|
||||||
def pytest_addoption(parser):
|
def pytest_addoption(parser):
|
||||||
parser.addoption("--req_client", action="store_true",
|
parser.addoption("--req_client", action="store_true",
|
||||||
help="Run tests that interact with a client")
|
help="Run tests that interact with a client")
|
||||||
|
|
||||||
|
|
||||||
def pytest_runtest_setup(item):
|
def pytest_runtest_setup(item):
|
||||||
|
@ -83,7 +70,6 @@ def a_movie(pms):
|
||||||
return m[0]
|
return m[0]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture()
|
@pytest.fixture()
|
||||||
def a_tv_section(pms):
|
def a_tv_section(pms):
|
||||||
sec = pms.library.section('TV Shows')
|
sec = pms.library.section('TV Shows')
|
||||||
|
@ -146,7 +132,6 @@ def a_episode(a_show):
|
||||||
return ep
|
return ep
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture()
|
@pytest.fixture()
|
||||||
def a_photo_album(pms):
|
def a_photo_album(pms):
|
||||||
sec = pms.library.section('Photos')
|
sec = pms.library.section('Photos')
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
def test_mark_movie_watched(a_movie):
|
def test_mark_movie_watched(a_movie):
|
||||||
a_movie.markUnwatched()
|
a_movie.markUnwatched()
|
||||||
print('Marking movie watched: %s' % a_movie)
|
print('Marking movie watched: %s' % a_movie)
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
|
||||||
def test_audio_Artist_attr(a_artist):
|
def test_audio_Artist_attr(a_artist):
|
||||||
m = a_artist
|
m = a_artist
|
||||||
m.reload()
|
m.reload()
|
||||||
|
@ -50,10 +49,6 @@ def test_audio_Artist_albums(a_artist):
|
||||||
assert len(albums) == 1 and albums[0].title == 'Unmastered Impulses'
|
assert len(albums) == 1 and albums[0].title == 'Unmastered Impulses'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_audio_Album_attrs(a_music_album):
|
def test_audio_Album_attrs(a_music_album):
|
||||||
m = a_music_album
|
m = a_music_album
|
||||||
assert str(m.addedAt.date()) == '2017-01-17'
|
assert str(m.addedAt.date()) == '2017-01-17'
|
||||||
|
@ -113,11 +108,9 @@ def test_audio_Album_tracks(a_music_album):
|
||||||
assert tracks[0].viewOffset == 0
|
assert tracks[0].viewOffset == 0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_audio_Album_track(a_music_album):
|
def test_audio_Album_track(a_music_album):
|
||||||
# this is not reloaded. its not that much info missing.
|
# this is not reloaded. its not that much info missing.
|
||||||
track = a_music_album.track('Holy Moment')
|
track = a_music_album.track('Holy Moment')
|
||||||
|
|
||||||
assert str(track.addedAt.date()) == '2017-01-17'
|
assert str(track.addedAt.date()) == '2017-01-17'
|
||||||
assert track.duration == 298606
|
assert track.duration == 298606
|
||||||
assert track.grandparentKey == '/library/metadata/20'
|
assert track.grandparentKey == '/library/metadata/20'
|
||||||
|
@ -176,12 +169,11 @@ def test_audio_Album_track(a_music_album):
|
||||||
assert par0.size == 14360402
|
assert par0.size == 14360402
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_audio_Album_get():
|
def test_audio_Album_get():
|
||||||
""" just a alias for track, lets skip it"""
|
""" Just a alias for track(); skip it. """
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def test_audio_Album_artist(a_music_album):
|
def test_audio_Album_artist(a_music_album):
|
||||||
artist = a_music_album.artist()
|
artist = a_music_album.artist()
|
||||||
artist.title == 'Infinite State'
|
artist.title == 'Infinite State'
|
||||||
|
@ -190,7 +182,6 @@ def test_audio_Album_artist(a_music_album):
|
||||||
def test_audio_Track_attrs(a_music_album):
|
def test_audio_Track_attrs(a_music_album):
|
||||||
track = a_music_album.get('Holy Moment')
|
track = a_music_album.get('Holy Moment')
|
||||||
track.reload()
|
track.reload()
|
||||||
|
|
||||||
assert str(track.addedAt.date()) == '2017-01-17'
|
assert str(track.addedAt.date()) == '2017-01-17'
|
||||||
assert str(track.art) == '__NA__'
|
assert str(track.art) == '__NA__'
|
||||||
assert str(track.chapterSource) == '__NA__'
|
assert str(track.chapterSource) == '__NA__'
|
||||||
|
@ -286,10 +277,10 @@ def test_audio_Track_attrs(a_music_album):
|
||||||
assert str0.type == 2
|
assert str0.type == 2
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_audio_Track_album(a_music_album):
|
def test_audio_Track_album(a_music_album):
|
||||||
assert a_music_album.tracks()[0].album() == a_music_album
|
assert a_music_album.tracks()[0].album() == a_music_album
|
||||||
|
|
||||||
|
|
||||||
def test_audio_Track_artist(a_music_album, a_artist):
|
def test_audio_Track_artist(a_music_album, a_artist):
|
||||||
assert a_music_album.tracks()[0].artist() == a_artist
|
assert a_music_album.tracks()[0].artist() == a_artist
|
||||||
|
|
||||||
|
@ -298,7 +289,6 @@ def test_audio_Audio_section(a_artist, a_music_album, a_track):
|
||||||
assert a_artist.section()
|
assert a_artist.section()
|
||||||
assert a_music_album.section()
|
assert a_music_album.section()
|
||||||
assert a_track.section()
|
assert a_track.section()
|
||||||
|
|
||||||
assert a_track.section() == a_music_album.section() == a_artist.section()
|
assert a_track.section() == a_music_album.section() == a_artist.section()
|
||||||
|
|
||||||
|
|
||||||
|
@ -315,16 +305,3 @@ def test_audio_album_download(monkeydownload, a_music_album, tmpdir):
|
||||||
def test_audio_Artist_download(monkeydownload, a_artist, tmpdir):
|
def test_audio_Artist_download(monkeydownload, a_artist, tmpdir):
|
||||||
f = a_artist.download(savepath=str(tmpdir))
|
f = a_artist.download(savepath=str(tmpdir))
|
||||||
assert len(f) == 14
|
assert len(f) == 14
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,173 +1,217 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.req_client
|
@pytest.mark.req_client
|
||||||
def _test_client_PlexClient__loadData(pms):
|
def _test_client_PlexClient__loadData(pms):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.req_client
|
@pytest.mark.req_client
|
||||||
def _test_client_PlexClient_connect(pms):
|
def _test_client_PlexClient_connect(pms):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.req_client
|
@pytest.mark.req_client
|
||||||
def _test_client_PlexClient_contextMenu(pms):
|
def _test_client_PlexClient_contextMenu(pms):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.req_client
|
@pytest.mark.req_client
|
||||||
def _test_client_PlexClient_goBack(pms):
|
def _test_client_PlexClient_goBack(pms):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.req_client
|
@pytest.mark.req_client
|
||||||
def _test_client_PlexClient_goToHome(pms):
|
def _test_client_PlexClient_goToHome(pms):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.req_client
|
@pytest.mark.req_client
|
||||||
def _test_client_PlexClient_goToMedia(pms):
|
def _test_client_PlexClient_goToMedia(pms):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.req_client
|
@pytest.mark.req_client
|
||||||
def _test_client_PlexClient_goToMusic(pms):
|
def _test_client_PlexClient_goToMusic(pms):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.req_client
|
@pytest.mark.req_client
|
||||||
def _test_client_PlexClient_headers(pms):
|
def _test_client_PlexClient_headers(pms):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.req_client
|
@pytest.mark.req_client
|
||||||
def _test_client_PlexClient_isPlayingMedia(pms):
|
def _test_client_PlexClient_isPlayingMedia(pms):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.req_client
|
@pytest.mark.req_client
|
||||||
def _test_client_PlexClient_moveDown(pms):
|
def _test_client_PlexClient_moveDown(pms):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.req_client
|
@pytest.mark.req_client
|
||||||
def _test_client_PlexClient_moveLeft(pms):
|
def _test_client_PlexClient_moveLeft(pms):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.req_client
|
@pytest.mark.req_client
|
||||||
def _test_client_PlexClient_moveRight(pms):
|
def _test_client_PlexClient_moveRight(pms):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.req_client
|
@pytest.mark.req_client
|
||||||
def _test_client_PlexClient_moveUp(pms):
|
def _test_client_PlexClient_moveUp(pms):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.req_client
|
@pytest.mark.req_client
|
||||||
def _test_client_PlexClient_nextLetter(pms):
|
def _test_client_PlexClient_nextLetter(pms):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.req_client
|
@pytest.mark.req_client
|
||||||
def _test_client_PlexClient_pageDown(pms):
|
def _test_client_PlexClient_pageDown(pms):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.req_client
|
@pytest.mark.req_client
|
||||||
def _test_client_PlexClient_pageUp(pms):
|
def _test_client_PlexClient_pageUp(pms):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.req_client
|
@pytest.mark.req_client
|
||||||
def _test_client_PlexClient_pause(pms):
|
def _test_client_PlexClient_pause(pms):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.req_client
|
@pytest.mark.req_client
|
||||||
def _test_client_PlexClient_play(pms):
|
def _test_client_PlexClient_play(pms):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.req_client
|
@pytest.mark.req_client
|
||||||
def _test_client_PlexClient_playMedia(pms):
|
def _test_client_PlexClient_playMedia(pms):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.req_client
|
@pytest.mark.req_client
|
||||||
def _test_client_PlexClient_previousLetter(pms):
|
def _test_client_PlexClient_previousLetter(pms):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.req_client
|
@pytest.mark.req_client
|
||||||
def _test_client_PlexClient_proxyThroughServer(pms):
|
def _test_client_PlexClient_proxyThroughServer(pms):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.req_client
|
@pytest.mark.req_client
|
||||||
def _test_client_PlexClient_query(pms):
|
def _test_client_PlexClient_query(pms):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.req_client
|
@pytest.mark.req_client
|
||||||
def _test_client_PlexClient_refreshPlayQueue(pms):
|
def _test_client_PlexClient_refreshPlayQueue(pms):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.req_client
|
@pytest.mark.req_client
|
||||||
def _test_client_PlexClient_seekTo(pms):
|
def _test_client_PlexClient_seekTo(pms):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.req_client
|
@pytest.mark.req_client
|
||||||
def _test_client_PlexClient_select(pms):
|
def _test_client_PlexClient_select(pms):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.req_client
|
@pytest.mark.req_client
|
||||||
def _test_client_PlexClient_sendCommand(pms):
|
def _test_client_PlexClient_sendCommand(pms):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.req_client
|
@pytest.mark.req_client
|
||||||
def _test_client_PlexClient_setAudioStream(pms):
|
def _test_client_PlexClient_setAudioStream(pms):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.req_client
|
@pytest.mark.req_client
|
||||||
def _test_client_PlexClient_setParameters(pms):
|
def _test_client_PlexClient_setParameters(pms):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.req_client
|
@pytest.mark.req_client
|
||||||
def _test_client_PlexClient_setRepeat(pms):
|
def _test_client_PlexClient_setRepeat(pms):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.req_client
|
@pytest.mark.req_client
|
||||||
def _test_client_PlexClient_setShuffle(pms):
|
def _test_client_PlexClient_setShuffle(pms):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.req_client
|
@pytest.mark.req_client
|
||||||
def _test_client_PlexClient_setStreams(pms):
|
def _test_client_PlexClient_setStreams(pms):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.req_client
|
@pytest.mark.req_client
|
||||||
def _test_client_PlexClient_setSubtitleStream(pms):
|
def _test_client_PlexClient_setSubtitleStream(pms):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.req_client
|
@pytest.mark.req_client
|
||||||
def _test_client_PlexClient_setVideoStream(pms):
|
def _test_client_PlexClient_setVideoStream(pms):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.req_client
|
@pytest.mark.req_client
|
||||||
def _test_client_PlexClient_setVolume(pms):
|
def _test_client_PlexClient_setVolume(pms):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.req_client
|
@pytest.mark.req_client
|
||||||
def _test_client_PlexClient_skipNext(pms):
|
def _test_client_PlexClient_skipNext(pms):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.req_client
|
@pytest.mark.req_client
|
||||||
def _test_client_PlexClient_skipPrevious(pms):
|
def _test_client_PlexClient_skipPrevious(pms):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.req_client
|
@pytest.mark.req_client
|
||||||
def _test_client_PlexClient_skipTo(pms):
|
def _test_client_PlexClient_skipTo(pms):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.req_client
|
@pytest.mark.req_client
|
||||||
def _test_client_PlexClient_stepBack(pms):
|
def _test_client_PlexClient_stepBack(pms):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.req_client
|
@pytest.mark.req_client
|
||||||
def _test_client_PlexClient_stepForward(pms):
|
def _test_client_PlexClient_stepForward(pms):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.req_client
|
@pytest.mark.req_client
|
||||||
def _test_client_PlexClient_stop(pms):
|
def _test_client_PlexClient_stop(pms):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.req_client
|
@pytest.mark.req_client
|
||||||
def _test_client_PlexClient_timeline(pms):
|
def _test_client_PlexClient_timeline(pms):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.req_client
|
@pytest.mark.req_client
|
||||||
def _test_client_PlexClient_toggleOSD(pms):
|
def _test_client_PlexClient_toggleOSD(pms):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.req_client
|
@pytest.mark.req_client
|
||||||
def _test_client_PlexClient_url(pms):
|
def _test_client_PlexClient_url(pms):
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -1,20 +1,14 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from plexapi.exceptions import NotFound
|
from plexapi.exceptions import NotFound
|
||||||
|
|
||||||
# func naming should follow:
|
|
||||||
# tests_file_class_method_some_description
|
|
||||||
|
|
||||||
|
|
||||||
def test_library_Library_section(pms):
|
def test_library_Library_section(pms):
|
||||||
sections = pms.library.sections()
|
sections = pms.library.sections()
|
||||||
assert len(sections) == 4
|
assert len(sections) == 4
|
||||||
|
|
||||||
lfs = 'TV Shows'
|
lfs = 'TV Shows'
|
||||||
section_name = pms.library.section(lfs)
|
section_name = pms.library.section(lfs)
|
||||||
assert section_name.title == lfs
|
assert section_name.title == lfs
|
||||||
|
|
||||||
with pytest.raises(NotFound):
|
with pytest.raises(NotFound):
|
||||||
assert pms.library.section('gfdsas')
|
assert pms.library.section('gfdsas')
|
||||||
|
|
||||||
|
@ -23,11 +17,9 @@ def test_library_Library_sectionByID_is_equal_section(pms, freshpms):
|
||||||
# test that sctionmyID refreshes the section if the key is missing
|
# test that sctionmyID refreshes the section if the key is missing
|
||||||
# this is needed if there isnt any cached sections
|
# this is needed if there isnt any cached sections
|
||||||
assert freshpms.library.sectionByID('1')
|
assert freshpms.library.sectionByID('1')
|
||||||
|
|
||||||
assert pms.library.sectionByID('1').uuid == pms.library.section('Movies').uuid
|
assert pms.library.sectionByID('1').uuid == pms.library.section('Movies').uuid
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_library_sectionByID_with_attrs(pms):
|
def test_library_sectionByID_with_attrs(pms):
|
||||||
m = pms.library.sectionByID('1')
|
m = pms.library.sectionByID('1')
|
||||||
assert m.agent == 'com.plexapp.agents.imdb'
|
assert m.agent == 'com.plexapp.agents.imdb'
|
||||||
|
@ -72,6 +64,7 @@ def test_library_get(pms):
|
||||||
m = pms.library.get('16 blocks')
|
m = pms.library.get('16 blocks')
|
||||||
assert m.title == '16 Blocks'
|
assert m.title == '16 Blocks'
|
||||||
|
|
||||||
|
|
||||||
def test_library_Library_cleanBundle(pms):
|
def test_library_Library_cleanBundle(pms):
|
||||||
pms.library.cleanBundles()
|
pms.library.cleanBundles()
|
||||||
|
|
||||||
|
@ -79,9 +72,11 @@ def test_library_Library_cleanBundle(pms):
|
||||||
def test_library_Library_optimize(pms):
|
def test_library_Library_optimize(pms):
|
||||||
pms.library.optimize()
|
pms.library.optimize()
|
||||||
|
|
||||||
|
|
||||||
def test_library_Library_emptyTrash(pms):
|
def test_library_Library_emptyTrash(pms):
|
||||||
pms.library.emptyTrash()
|
pms.library.emptyTrash()
|
||||||
|
|
||||||
|
|
||||||
def _test_library_Library_refresh(pms):
|
def _test_library_Library_refresh(pms):
|
||||||
pms.library.refresh() # fix mangle and proof the sections attrs
|
pms.library.refresh() # fix mangle and proof the sections attrs
|
||||||
|
|
||||||
|
@ -134,18 +129,11 @@ def test_library_PhotoSection_searchAlbums(a_photo_section):
|
||||||
print([i.TYPE for i in albums])
|
print([i.TYPE for i in albums])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_library_PhotoSection_searchPhotos(a_photo_section):
|
def test_library_PhotoSection_searchPhotos(a_photo_section):
|
||||||
assert len(a_photo_section.searchPhotos('lolcat2'))
|
assert len(a_photo_section.searchPhotos('lolcat2'))
|
||||||
|
|
||||||
|
|
||||||
|
# Start on library search
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### Start on library search
|
|
||||||
|
|
||||||
def test_library_and_section_search_for_movie(pms):
|
def test_library_and_section_search_for_movie(pms):
|
||||||
find = '16 blocks'
|
find = '16 blocks'
|
||||||
l_search = pms.library.search(find)
|
l_search = pms.library.search(find)
|
||||||
|
@ -157,7 +145,6 @@ def test_search_with_apostrophe(pms):
|
||||||
show_title = "Marvel's Daredevil" # Test ' in show title
|
show_title = "Marvel's Daredevil" # Test ' in show title
|
||||||
result_server = pms.search(show_title)
|
result_server = pms.search(show_title)
|
||||||
result_shows = pms.library.section('TV Shows').search(show_title)
|
result_shows = pms.library.section('TV Shows').search(show_title)
|
||||||
|
|
||||||
assert result_server
|
assert result_server
|
||||||
assert result_shows
|
assert result_shows
|
||||||
assert result_server == result_shows
|
assert result_server == result_shows
|
||||||
|
@ -166,7 +153,6 @@ def test_search_with_apostrophe(pms):
|
||||||
def test_crazy_search(pms, a_movie):
|
def test_crazy_search(pms, a_movie):
|
||||||
movie = a_movie
|
movie = a_movie
|
||||||
movies = pms.library.section('Movies')
|
movies = pms.library.section('Movies')
|
||||||
|
|
||||||
assert movie in pms.library.search(genre=29, libtype='movie')
|
assert movie in pms.library.search(genre=29, libtype='movie')
|
||||||
assert movie in movies.search(actor=movie.actors[0], sort='titleSort'), 'Unable to search movie by actor.'
|
assert movie in movies.search(actor=movie.actors[0], sort='titleSort'), 'Unable to search movie by actor.'
|
||||||
assert movie in movies.search(director=movie.directors[0]), 'Unable to search movie by director.'
|
assert movie in movies.search(director=movie.directors[0]), 'Unable to search movie by director.'
|
||||||
|
|
|
@ -1,13 +1,10 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import pytest
|
|
||||||
|
|
||||||
|
|
||||||
def test_myplex_accounts(plex_account, pms):
|
def test_myplex_accounts(plex_account, pms):
|
||||||
account = plex_account
|
account = plex_account
|
||||||
assert account, 'Must specify username, password & resource to run this test.'
|
assert account, 'Must specify username, password & resource to run this test.'
|
||||||
print('MyPlexAccount:')
|
print('MyPlexAccount:')
|
||||||
print('username: %s' % account.username)
|
print('username: %s' % account.username)
|
||||||
#print('authenticationToken: %s' % account.authenticationToken)
|
|
||||||
print('email: %s' % account.email)
|
print('email: %s' % account.email)
|
||||||
print('home: %s' % account.home)
|
print('home: %s' % account.home)
|
||||||
print('queueEmail: %s' % account.queueEmail)
|
print('queueEmail: %s' % account.queueEmail)
|
||||||
|
@ -57,7 +54,7 @@ def test_myplex_devices(plex_account):
|
||||||
assert devices, 'No devices found for account: %s' % account.name
|
assert devices, 'No devices found for account: %s' % account.name
|
||||||
|
|
||||||
|
|
||||||
#@pytest.mark.req_client # this need to be recorded?
|
#@pytest.mark.req_client # this need to be recorded?
|
||||||
def _test_myplex_connect_to_device(plex_account):
|
def _test_myplex_connect_to_device(plex_account):
|
||||||
account = plex_account
|
account = plex_account
|
||||||
devices = account.devices()
|
devices = account.devices()
|
||||||
|
|
|
@ -1,16 +1,11 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import pytest
|
|
||||||
|
|
||||||
|
|
||||||
def test_navigate_around_show(plex_account, pms):
|
def test_navigate_around_show(plex_account, pms):
|
||||||
show = pms.library.section('TV Shows').get('The 100')
|
show = pms.library.section('TV Shows').get('The 100')
|
||||||
seasons = show.seasons()
|
seasons = show.seasons()
|
||||||
season = show.season('Season 1')
|
season = show.season('Season 1')
|
||||||
|
|
||||||
episodes = show.episodes()
|
episodes = show.episodes()
|
||||||
episode = show.episode('Pilot')
|
episode = show.episode('Pilot')
|
||||||
|
|
||||||
assert 'Season 1' in [s.title for s in seasons], 'Unable to list season:'
|
assert 'Season 1' in [s.title for s in seasons], 'Unable to list season:'
|
||||||
assert 'Pilot' in [e.title for e in episodes], 'Unable to list episode:'
|
assert 'Pilot' in [e.title for e in episodes], 'Unable to list episode:'
|
||||||
assert show.season(1) == season
|
assert show.season(1) == season
|
||||||
|
@ -21,22 +16,22 @@ def test_navigate_around_show(plex_account, pms):
|
||||||
assert episode.season() == season, 'episode.season() doesnt match expected season.'
|
assert episode.season() == season, 'episode.season() doesnt match expected season.'
|
||||||
|
|
||||||
|
|
||||||
def _test_navigate_around_artist(plex_account, pms):
|
def test_navigate_around_artist(plex_account, pms):
|
||||||
artist = pms.library.section(CONFIG.audio_section).get(CONFIG.audio_artist)
|
artist = pms.library.section('Music').get('Infinite State')
|
||||||
albums = artist.albums()
|
albums = artist.albums()
|
||||||
album = artist.album(CONFIG.audio_album)
|
album = artist.album('Unmastered Impulses')
|
||||||
tracks = artist.tracks()
|
tracks = artist.tracks()
|
||||||
track = artist.track(CONFIG.audio_track)
|
track = artist.track('Mantra')
|
||||||
print('Navigating around artist: %s' % artist)
|
print('Navigating around artist: %s' % artist)
|
||||||
print('Albums: %s...' % albums[:3])
|
print('Albums: %s...' % albums[:3])
|
||||||
print('Album: %s' % album)
|
print('Album: %s' % album)
|
||||||
print('Tracks: %s...' % tracks[:3])
|
print('Tracks: %s...' % tracks[:3])
|
||||||
print('Track: %s' % track)
|
print('Track: %s' % track)
|
||||||
assert CONFIG.audio_album in [a.title for a in albums], 'Unable to list album: %s' % CONFIG.audio_album
|
assert 'Unmastered Impulses' in [a.title for a in albums], 'Unable to list album.'
|
||||||
assert CONFIG.audio_track in [e.title for e in tracks], 'Unable to list track: %s' % CONFIG.audio_track
|
assert 'Mantra' in [e.title for e in tracks], 'Unable to list track.'
|
||||||
assert artist.album(CONFIG.audio_album) == album, 'Unable to get artist album: %s' % CONFIG.audio_album
|
assert artist.album('Unmastered Impulses') == album, 'Unable to get artist album.'
|
||||||
assert artist.track(CONFIG.audio_track) == track, 'Unable to get artist track: %s' % CONFIG.audio_track
|
assert artist.track('Mantra') == track, 'Unable to get artist track.'
|
||||||
assert album.track(CONFIG.audio_track) == track, 'Unable to get album track: %s' % CONFIG.audio_track
|
assert album.track('Mantra') == track, 'Unable to get album track.'
|
||||||
assert album.artist() == artist, 'album.artist() doesnt match expected artist.'
|
assert album.artist() == artist, 'album.artist() doesnt match expected artist.'
|
||||||
assert track.artist() == artist, 'track.artist() doesnt match expected artist.'
|
assert track.artist() == artist, 'track.artist() doesnt match expected artist.'
|
||||||
assert track.album() == album, 'track.album() doesnt match expected album.'
|
assert track.album() == album, 'track.album() doesnt match expected album.'
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import time
|
import pytest, time
|
||||||
import pytest
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_create_playlist(pms, a_show):
|
def test_create_playlist(pms, a_show):
|
||||||
|
@ -68,13 +64,10 @@ def test_playlist_play(pms):
|
||||||
pl_name = 'test_play_playlist'
|
pl_name = 'test_play_playlist'
|
||||||
playlist = plex.createPlaylist(pl_name, album)
|
playlist = plex.createPlaylist(pl_name, album)
|
||||||
try:
|
try:
|
||||||
#print('Playing playlist: %s' % playlist)
|
|
||||||
client.playMedia(playlist); time.sleep(5)
|
client.playMedia(playlist); time.sleep(5)
|
||||||
#print('stop..')
|
|
||||||
client.stop('music'); time.sleep(1)
|
client.stop('music'); time.sleep(1)
|
||||||
finally:
|
finally:
|
||||||
playlist.delete()
|
playlist.delete()
|
||||||
|
|
||||||
assert pl_name not in [i.title for i in pms.playlists()]
|
assert pl_name not in [i.title for i in pms.playlists()]
|
||||||
|
|
||||||
|
|
||||||
|
@ -83,12 +76,10 @@ def test_playlist_photos(pms, a_photo_album):
|
||||||
photos = album.photos()
|
photos = album.photos()
|
||||||
pl_name = 'test_playlist_photos'
|
pl_name = 'test_playlist_photos'
|
||||||
playlist = pms.createPlaylist(pl_name, photos)
|
playlist = pms.createPlaylist(pl_name, photos)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
assert len(playlist.items()) == 4
|
assert len(playlist.items()) == 4
|
||||||
finally:
|
finally:
|
||||||
playlist.delete()
|
playlist.delete()
|
||||||
|
|
||||||
assert pl_name not in [i.title for i in pms.playlists()]
|
assert pl_name not in [i.title for i in pms.playlists()]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,2 @@
|
||||||
# test search.
|
# -*- coding: utf-8 -*-
|
||||||
|
# TODO: Many more tests is for search later.
|
||||||
# Many more tests is for search later.
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import pytest
|
# -*- coding: utf-8 -*-
|
||||||
import os
|
import os, pytest
|
||||||
|
|
||||||
from plexapi.exceptions import BadRequest, NotFound
|
from plexapi.exceptions import BadRequest, NotFound
|
||||||
from plexapi.utils import download
|
from plexapi.utils import download
|
||||||
|
|
||||||
|
@ -38,62 +37,52 @@ def test_server_url(pms):
|
||||||
|
|
||||||
def test_server_transcodeImage(tmpdir, pms, a_show):
|
def test_server_transcodeImage(tmpdir, pms, a_show):
|
||||||
# Ideally we should also test the black white but this has to do for now.
|
# Ideally we should also test the black white but this has to do for now.
|
||||||
height = 500
|
from PIL import Image
|
||||||
width = 500
|
width, height = 500, 500
|
||||||
img_url_resize = pms.transcodeImage(a_show.banner, height, width)
|
img_url_resize = pms.transcodeImage(a_show.banner, height, width)
|
||||||
gray = img_url_resize = pms.transcodeImage(a_show.banner, height, width, saturation=0)
|
gray = img_url_resize = pms.transcodeImage(a_show.banner, height, width, saturation=0)
|
||||||
|
|
||||||
resized_image = download(img_url_resize, savepath=str(tmpdir), filename='resize_image')
|
resized_image = download(img_url_resize, savepath=str(tmpdir), filename='resize_image')
|
||||||
org_image = download(a_show.server.url(a_show.banner), savepath=str(tmpdir), filename='org_image')
|
org_image = download(a_show.server.url(a_show.banner), savepath=str(tmpdir), filename='org_image')
|
||||||
gray_image = download(gray, savepath=str(tmpdir), filename='gray_image')
|
gray_image = download(gray, savepath=str(tmpdir), filename='gray_image')
|
||||||
|
|
||||||
|
|
||||||
from PIL import Image, ImageStat
|
|
||||||
|
|
||||||
with Image.open(resized_image) as im:
|
with Image.open(resized_image) as im:
|
||||||
assert width, height == im.size
|
assert width, height == im.size
|
||||||
|
|
||||||
with Image.open(org_image) as im:
|
with Image.open(org_image) as im:
|
||||||
assert width, height != im.size
|
assert width, height != im.size
|
||||||
|
assert _detect_color_image(gray_image, thumb_size=150) == 'grayscale'
|
||||||
|
|
||||||
|
|
||||||
|
def _detect_color_image(file, thumb_size=150, MSE_cutoff=22, adjust_color_bias=True):
|
||||||
def detect_color_image(file, thumb_size=150, MSE_cutoff=22, adjust_color_bias=True):
|
# from http://stackoverflow.com/questions/20068945/detect-if-image-is-color-grayscale-or-black-and-white-with-python-pil
|
||||||
#from http://stackoverflow.com/questions/20068945/detect-if-image-is-color-grayscale-or-black-and-white-with-python-pil
|
from PIL import Image, ImageStat
|
||||||
pil_img = Image.open(file)
|
pil_img = Image.open(file)
|
||||||
bands = pil_img.getbands()
|
bands = pil_img.getbands()
|
||||||
if bands == ('R', 'G', 'B') or bands == ('R', 'G', 'B', 'A'):
|
if bands == ('R', 'G', 'B') or bands == ('R', 'G', 'B', 'A'):
|
||||||
thumb = pil_img.resize((thumb_size, thumb_size))
|
thumb = pil_img.resize((thumb_size, thumb_size))
|
||||||
SSE, bias = 0, [0, 0, 0]
|
SSE, bias = 0, [0, 0, 0]
|
||||||
if adjust_color_bias:
|
if adjust_color_bias:
|
||||||
bias = ImageStat.Stat(thumb).mean[:3]
|
bias = ImageStat.Stat(thumb).mean[:3]
|
||||||
bias = [b - sum(bias) / 3 for b in bias]
|
bias = [b - sum(bias) / 3 for b in bias]
|
||||||
for pixel in thumb.getdata():
|
for pixel in thumb.getdata():
|
||||||
mu = sum(pixel) / 3
|
mu = sum(pixel) / 3
|
||||||
SSE += sum((pixel[i] - mu - bias[i]) * (pixel[i] - mu - bias[i]) for i in [0, 1, 2])
|
SSE += sum((pixel[i] - mu - bias[i]) * (pixel[i] - mu - bias[i]) for i in [0, 1, 2])
|
||||||
MSE = float(SSE) / (thumb_size * thumb_size)
|
MSE = float(SSE) / (thumb_size * thumb_size)
|
||||||
if MSE <= MSE_cutoff:
|
if MSE <= MSE_cutoff:
|
||||||
return 'grayscale'
|
return 'grayscale'
|
||||||
else:
|
else:
|
||||||
return 'color'
|
return 'color'
|
||||||
elif len(bands) == 1:
|
elif len(bands) == 1:
|
||||||
return 'blackandwhite'
|
return 'blackandwhite'
|
||||||
|
|
||||||
assert detect_color_image(gray_image, thumb_size=150) == 'grayscale'
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_server_search(pms):
|
def test_server_search(pms):
|
||||||
# basic search. see test_search.py
|
# basic search. see test_search.py
|
||||||
assert pms.search('16 Blocks')
|
assert pms.search('16 Blocks')
|
||||||
|
|
||||||
assert pms.search('16 blocks', mediatype='movie')
|
assert pms.search('16 blocks', mediatype='movie')
|
||||||
|
|
||||||
|
|
||||||
def test_server_playlist(pms):
|
def test_server_playlist(pms):
|
||||||
pl = pms.playlist('some_playlist')
|
pl = pms.playlist('some_playlist')
|
||||||
assert pl.title == 'some_playlist'
|
assert pl.title == 'some_playlist'
|
||||||
|
|
||||||
with pytest.raises(NotFound):
|
with pytest.raises(NotFound):
|
||||||
pms.playlist('124xxx11y')
|
pms.playlist('124xxx11y')
|
||||||
|
|
||||||
|
@ -110,19 +99,15 @@ def test_server_history(pms):
|
||||||
|
|
||||||
def test_server_Server_query(pms):
|
def test_server_Server_query(pms):
|
||||||
assert pms.query('/')
|
assert pms.query('/')
|
||||||
|
|
||||||
from plexapi.server import PlexServer
|
from plexapi.server import PlexServer
|
||||||
|
|
||||||
with pytest.raises(BadRequest):
|
with pytest.raises(BadRequest):
|
||||||
assert pms.query('/asdasdsada/12123127/aaaa', headers={'random_headers': '1337'})
|
assert pms.query('/asdasdsada/12123127/aaaa', headers={'random_headers': '1337'})
|
||||||
|
|
||||||
with pytest.raises(NotFound):
|
with pytest.raises(NotFound):
|
||||||
# This is really requests.exceptions.HTTPError:
|
# This is really requests.exceptions.HTTPError:
|
||||||
# 401 Client Error: Unauthorized for url:
|
# 401 Client Error: Unauthorized for url:
|
||||||
PlexServer('http://138.68.157.5:32400', '1234')
|
PlexServer('http://138.68.157.5:32400', '1234')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_server_Server_session():
|
def test_server_Server_session():
|
||||||
from requests import Session
|
from requests import Session
|
||||||
from plexapi.server import PlexServer
|
from plexapi.server import PlexServer
|
||||||
|
@ -133,17 +118,12 @@ def test_server_Server_session():
|
||||||
self.plexapi_session_test = True
|
self.plexapi_session_test = True
|
||||||
|
|
||||||
plex = PlexServer('http://138.68.157.5:32400',
|
plex = PlexServer('http://138.68.157.5:32400',
|
||||||
os.environ.get('PLEX_TEST_TOKEN'),
|
os.environ.get('PLEX_TEST_TOKEN'), session=MySession())
|
||||||
session=MySession())
|
|
||||||
|
|
||||||
assert hasattr(plex.session, 'plexapi_session_test')
|
assert hasattr(plex.session, 'plexapi_session_test')
|
||||||
|
|
||||||
pl = plex.playlists()
|
pl = plex.playlists()
|
||||||
assert hasattr(pl[0].server.session, 'plexapi_session_test')
|
assert hasattr(pl[0].server.session, 'plexapi_session_test')
|
||||||
|
# TODO: Check client in test_server_Server_session.
|
||||||
# check client
|
# TODO: Check myplex in test_server_Server_session.
|
||||||
# check myplex.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_server_token_in_headers(pms):
|
def test_server_token_in_headers(pms):
|
||||||
|
@ -155,6 +135,7 @@ def _test_server_createPlayQueue():
|
||||||
# see test_playlists.py
|
# see test_playlists.py
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def _test_server_createPlaylist():
|
def _test_server_createPlaylist():
|
||||||
# see test_playlists.py
|
# see test_playlists.py
|
||||||
pass
|
pass
|
||||||
|
@ -162,13 +143,14 @@ def _test_server_createPlaylist():
|
||||||
|
|
||||||
def test_server_client_not_found(pms):
|
def test_server_client_not_found(pms):
|
||||||
with pytest.raises(NotFound):
|
with pytest.raises(NotFound):
|
||||||
pms.client('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
|
pms.client('<This-client-should-not-be-found>')
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.req_client
|
@pytest.mark.req_client
|
||||||
def test_server_client(pms):
|
def test_server_client(pms):
|
||||||
assert pms.client('Plex Web (Chrome)')
|
assert pms.client('Plex Web (Chrome)')
|
||||||
|
|
||||||
|
|
||||||
def test_server_Server_sessions(pms):
|
def test_server_Server_sessions(pms):
|
||||||
assert len(pms.sessions()) == 0
|
assert len(pms.sessions()) == 0
|
||||||
|
|
||||||
|
@ -189,7 +171,6 @@ def test_server_clients(pms):
|
||||||
assert m.protocolCapabilities == ['timeline', 'playback', 'navigation', 'mirror', 'playqueues']
|
assert m.protocolCapabilities == ['timeline', 'playback', 'navigation', 'mirror', 'playqueues']
|
||||||
assert m.protocolVersion == '1'
|
assert m.protocolVersion == '1'
|
||||||
assert m.server.baseurl == 'http://138.68.157.5:32400'
|
assert m.server.baseurl == 'http://138.68.157.5:32400'
|
||||||
#assert m.session == <requests.sessions.Session object at 0x02945E10>
|
|
||||||
assert m.state is None
|
assert m.state is None
|
||||||
assert m.title == 'Plex Web (Chrome)'
|
assert m.title == 'Plex Web (Chrome)'
|
||||||
assert m.token is None
|
assert m.token is None
|
||||||
|
@ -200,7 +181,8 @@ def test_server_clients(pms):
|
||||||
def test_server_account(pms):
|
def test_server_account(pms):
|
||||||
acc = pms.account()
|
acc = pms.account()
|
||||||
assert acc.authToken
|
assert acc.authToken
|
||||||
#assert acc.mappingError == 'publisherror' # this is missing from time to time.. why?
|
# TODO: Figure out why this is missing from time to time.
|
||||||
|
#assert acc.mappingError == 'publisherror'
|
||||||
assert acc.mappingErrorMessage is None
|
assert acc.mappingErrorMessage is None
|
||||||
assert acc.mappingState == 'mapped'
|
assert acc.mappingState == 'mapped'
|
||||||
assert acc.privateAddress == '138.68.157.5'
|
assert acc.privateAddress == '138.68.157.5'
|
||||||
|
@ -212,5 +194,3 @@ def test_server_account(pms):
|
||||||
assert acc.subscriptionFeatures is None
|
assert acc.subscriptionFeatures is None
|
||||||
assert acc.subscriptionState == 'Unknown'
|
assert acc.subscriptionState == 'Unknown'
|
||||||
assert acc.username == 'testplexapi@gmail.com'
|
assert acc.username == 'testplexapi@gmail.com'
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
import plexapi.utils as utils
|
import plexapi.utils as utils
|
||||||
from plexapi.exceptions import NotFound
|
from plexapi.exceptions import NotFound
|
||||||
|
|
||||||
|
@ -10,24 +9,28 @@ def test_utils_toDatetime():
|
||||||
assert str(utils.toDatetime('0'))[:-9] == '1970-01-01'
|
assert str(utils.toDatetime('0'))[:-9] == '1970-01-01'
|
||||||
# should this handle args as '0' # no need element attrs are strings.
|
# should this handle args as '0' # no need element attrs are strings.
|
||||||
|
|
||||||
|
|
||||||
def _test_utils_threaded():
|
def _test_utils_threaded():
|
||||||
|
# TODO: Implement test_utils_threaded
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def test_utils_searchType():
|
def test_utils_searchType():
|
||||||
st = utils.searchType('movie')
|
st = utils.searchType('movie')
|
||||||
assert st == 1
|
assert st == 1
|
||||||
|
|
||||||
movie = utils.searchType(1)
|
movie = utils.searchType(1)
|
||||||
assert movie == '1'
|
assert movie == '1'
|
||||||
|
|
||||||
with pytest.raises(NotFound):
|
with pytest.raises(NotFound):
|
||||||
utils.searchType('kekekekeke')
|
utils.searchType('kekekekeke')
|
||||||
|
|
||||||
|
|
||||||
def _test_utils_listItems():
|
def _test_utils_listItems():
|
||||||
|
# TODO: Implement test_utils_listItems
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def _test_utils_listChoices(pms):
|
def _test_utils_listChoices(pms):
|
||||||
|
# TODO: Implement test_utils_listChoices
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@ -41,27 +44,35 @@ def test_utils_isInt():
|
||||||
assert utils.isInt('got_you') is False
|
assert utils.isInt('got_you') is False
|
||||||
assert utils.isInt('1337') is True
|
assert utils.isInt('1337') is True
|
||||||
|
|
||||||
|
|
||||||
def _test_utils_findUsername():
|
def _test_utils_findUsername():
|
||||||
|
# TODO: Implement test_utils_findUsername
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def _test_utils_findStreams():
|
def _test_utils_findStreams():
|
||||||
|
# TODO: Implement test_utils_findStreams
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def _test_utils_findPlayer():
|
def _test_utils_findPlayer():
|
||||||
|
# TODO: Implement test_utils_findPlayer
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def _test_utils_findLocations():
|
def _test_utils_findLocations():
|
||||||
|
# TODO: Implement test_utils_findLocations
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def _test_utils_findItem():
|
def _test_utils_findItem():
|
||||||
|
# TODO: Implement test_utils_findItem
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def test_utils_findKey(pms):
|
def test_utils_findKey(pms):
|
||||||
with pytest.raises(NotFound):
|
with pytest.raises(NotFound):
|
||||||
assert utils.findKey(pms, '9999999')
|
assert utils.findKey(pms, '9999999')
|
||||||
|
|
||||||
assert utils.findKey(pms, '1')
|
assert utils.findKey(pms, '1')
|
||||||
|
|
||||||
|
|
||||||
|
@ -79,22 +90,18 @@ def test_utils_cast():
|
||||||
assert t_bool_int is True
|
assert t_bool_int is True
|
||||||
assert t_float_float == 1.0 and isinstance(t_float_float, float)
|
assert t_float_float == 1.0 and isinstance(t_float_float, float)
|
||||||
assert t_float_str != t_float_str # nan is never equal
|
assert t_float_str != t_float_str # nan is never equal
|
||||||
|
|
||||||
with pytest.raises(ValueError):
|
with pytest.raises(ValueError):
|
||||||
t_bool_str = utils.cast(bool, 'kek') # should we catch this in cast?
|
t_bool_str = utils.cast(bool, 'kek') # should we catch this in cast?
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_utils_download(a_episode):
|
def test_utils_download(a_episode):
|
||||||
# this files is really getting downloaded..
|
# this files is really getting downloaded..
|
||||||
without_session = utils.download(a_episode.getStreamURL(), filename=a_episode.location, mocked=True)
|
without_session = utils.download(a_episode.getStreamURL(),
|
||||||
|
filename=a_episode.location, mocked=True)
|
||||||
assert without_session
|
assert without_session
|
||||||
|
|
||||||
with_session = utils.download(a_episode.getStreamURL(),
|
with_session = utils.download(a_episode.getStreamURL(),
|
||||||
filename=a_episode.location,
|
filename=a_episode.location, session=a_episode.server.session,
|
||||||
session=a_episode.server.session,
|
mocked=True)
|
||||||
mocked=True)
|
|
||||||
assert with_session
|
assert with_session
|
||||||
|
|
||||||
img = utils.download(a_episode.thumbUrl, filename=a_episode.title, mocked=True)
|
img = utils.download(a_episode.thumbUrl, filename=a_episode.title, mocked=True)
|
||||||
assert img
|
assert img
|
||||||
|
|
|
@ -1,10 +1,5 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
#test_the_file_class_method
|
import os, pytest
|
||||||
|
|
||||||
import os
|
|
||||||
|
|
||||||
import pytest
|
|
||||||
|
|
||||||
from plexapi.exceptions import NotFound
|
from plexapi.exceptions import NotFound
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,21 +7,21 @@ def test_video_Movie(a_movie_section):
|
||||||
m = a_movie_section.get('Cars')
|
m = a_movie_section.get('Cars')
|
||||||
assert m.title == 'Cars'
|
assert m.title == 'Cars'
|
||||||
|
|
||||||
|
|
||||||
def test_video_Movie_getStreamURL(a_movie):
|
def test_video_Movie_getStreamURL(a_movie):
|
||||||
assert a_movie.getStreamURL() == "http://138.68.157.5:32400/video/:/transcode/universal/start.m3u8?X-Plex-Platform=Chrome©ts=1&mediaIndex=0&offset=0&path=%2Flibrary%2Fmetadata%2F1&X-Plex-Token={0}".format(os.environ.get('PLEX_TEST_TOKEN'))
|
assert a_movie.getStreamURL() == "http://138.68.157.5:32400/video/:/transcode/universal/start.m3u8?X-Plex-Platform=Chrome©ts=1&mediaIndex=0&offset=0&path=%2Flibrary%2Fmetadata%2F1&X-Plex-Token={0}".format(os.environ.get('PLEX_TEST_TOKEN'))
|
||||||
assert a_movie.getStreamURL(videoResolution='800x600') == "http://138.68.157.5:32400/video/:/transcode/universal/start.m3u8?X-Plex-Platform=Chrome©ts=1&mediaIndex=0&offset=0&path=%2Flibrary%2Fmetadata%2F1&videoResolution=800x600&X-Plex-Token={0}".format(os.environ.get('PLEX_TEST_TOKEN'))
|
assert a_movie.getStreamURL(videoResolution='800x600') == "http://138.68.157.5:32400/video/:/transcode/universal/start.m3u8?X-Plex-Platform=Chrome©ts=1&mediaIndex=0&offset=0&path=%2Flibrary%2Fmetadata%2F1&videoResolution=800x600&X-Plex-Token={0}".format(os.environ.get('PLEX_TEST_TOKEN'))
|
||||||
|
|
||||||
|
|
||||||
def test_video_Movie_isFullObject_and_reload(pms):
|
def test_video_Movie_isFullObject_and_reload(pms):
|
||||||
movie = pms.library.section('Movies').get('16 Blocks')
|
movie = pms.library.section('Movies').get('16 Blocks')
|
||||||
assert movie.isFullObject() is False
|
assert movie.isFullObject() is False
|
||||||
movie.reload()
|
movie.reload()
|
||||||
assert movie.isFullObject() is True
|
assert movie.isFullObject() is True
|
||||||
|
|
||||||
movie_via_search = pms.library.search('16 Blocks')[0]
|
movie_via_search = pms.library.search('16 Blocks')[0]
|
||||||
assert movie_via_search.isFullObject() is False
|
assert movie_via_search.isFullObject() is False
|
||||||
movie_via_search.reload()
|
movie_via_search.reload()
|
||||||
assert movie_via_search.isFullObject() is True
|
assert movie_via_search.isFullObject() is True
|
||||||
|
|
||||||
movie_via_section_search = pms.library.section('Movies').search('16 Blocks')[0]
|
movie_via_section_search = pms.library.section('Movies').search('16 Blocks')[0]
|
||||||
assert movie_via_section_search.isFullObject() is False
|
assert movie_via_section_search.isFullObject() is False
|
||||||
movie_via_section_search.reload()
|
movie_via_section_search.reload()
|
||||||
|
@ -42,19 +37,16 @@ def test_video_Movie_isPartialObject(a_movie):
|
||||||
def test_video_Movie_iterParts(a_movie):
|
def test_video_Movie_iterParts(a_movie):
|
||||||
assert len(list(a_movie.iterParts())) == 1
|
assert len(list(a_movie.iterParts())) == 1
|
||||||
|
|
||||||
|
|
||||||
def test_video_Movie_download(monkeydownload, tmpdir, a_movie):
|
def test_video_Movie_download(monkeydownload, tmpdir, a_movie):
|
||||||
downloaded_movie = a_movie.download(savepath=str(tmpdir))
|
downloaded_movie = a_movie.download(savepath=str(tmpdir))
|
||||||
assert len(downloaded_movie) == 1
|
assert len(downloaded_movie) == 1
|
||||||
|
|
||||||
downloaded_movie2 = a_movie.download(savepath=str(tmpdir), **{'videoResolution': '500x300'})
|
downloaded_movie2 = a_movie.download(savepath=str(tmpdir), **{'videoResolution': '500x300'})
|
||||||
assert len(downloaded_movie2) == 1
|
assert len(downloaded_movie2) == 1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_video_Movie_attrs_as_much_as_possible(a_movie_section):
|
def test_video_Movie_attrs_as_much_as_possible(a_movie_section):
|
||||||
m = a_movie_section.get('Cars')
|
m = a_movie_section.get('Cars')
|
||||||
|
|
||||||
assert m.location == '/media/movies/cars/cars.mp4'
|
assert m.location == '/media/movies/cars/cars.mp4'
|
||||||
assert str(m.addedAt.date()) == '2017-01-17'
|
assert str(m.addedAt.date()) == '2017-01-17'
|
||||||
assert m.art == '/library/metadata/2/art/1484690715'
|
assert m.art == '/library/metadata/2/art/1484690715'
|
||||||
|
@ -239,7 +231,6 @@ def test_video_Movie_attrs_as_much_as_possible(a_movie_section):
|
||||||
assert str1.type == 2
|
assert str1.type == 2
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_video_Show(a_show):
|
def test_video_Show(a_show):
|
||||||
assert a_show.title == 'The 100'
|
assert a_show.title == 'The 100'
|
||||||
|
|
||||||
|
@ -286,9 +277,11 @@ def test_video_Show_watched(a_show):
|
||||||
watched = a_show.watched()
|
watched = a_show.watched()
|
||||||
assert len(watched) == 1 and watched[0].title == 'Pilot'
|
assert len(watched) == 1 and watched[0].title == 'Pilot'
|
||||||
|
|
||||||
|
|
||||||
def test_video_Show_unwatched(a_show):
|
def test_video_Show_unwatched(a_show):
|
||||||
assert len(a_show.unwatched()) == 8
|
assert len(a_show.unwatched()) == 8
|
||||||
|
|
||||||
|
|
||||||
def test_video_Show_location(pms):
|
def test_video_Show_location(pms):
|
||||||
# This should be a part of test test_video_Show_attrs
|
# This should be a part of test test_video_Show_attrs
|
||||||
# But is excluded because of https://github.com/mjs7231/python-plexapi/issues/97
|
# But is excluded because of https://github.com/mjs7231/python-plexapi/issues/97
|
||||||
|
@ -305,13 +298,13 @@ def test_video_Show_reload(pms):
|
||||||
assert len(s.roles) > 3
|
assert len(s.roles) > 3
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_video_Show_episodes(a_show):
|
def test_video_Show_episodes(a_show):
|
||||||
inc_watched = a_show.episodes()
|
inc_watched = a_show.episodes()
|
||||||
ex_watched = a_show.episodes(watched=False)
|
ex_watched = a_show.episodes(watched=False)
|
||||||
assert len(inc_watched) == 9
|
assert len(inc_watched) == 9
|
||||||
assert len(ex_watched) == 8
|
assert len(ex_watched) == 8
|
||||||
|
|
||||||
|
|
||||||
def test_video_Show_download(monkeydownload, tmpdir, a_show):
|
def test_video_Show_download(monkeydownload, tmpdir, a_show):
|
||||||
f = a_show.download(savepath=str(tmpdir))
|
f = a_show.download(savepath=str(tmpdir))
|
||||||
assert len(f) == 9
|
assert len(f) == 9
|
||||||
|
@ -319,27 +312,26 @@ def test_video_Show_download(monkeydownload, tmpdir, a_show):
|
||||||
|
|
||||||
def test_video_Season_download(monkeydownload, tmpdir, a_show):
|
def test_video_Season_download(monkeydownload, tmpdir, a_show):
|
||||||
sn = a_show.season('Season 1')
|
sn = a_show.season('Season 1')
|
||||||
|
|
||||||
f = sn.download(savepath=str(tmpdir))
|
f = sn.download(savepath=str(tmpdir))
|
||||||
assert len(f) == 8
|
assert len(f) == 8
|
||||||
|
|
||||||
|
|
||||||
def test_video_Episode_download(monkeydownload, tmpdir, a_episode):
|
def test_video_Episode_download(monkeydownload, tmpdir, a_episode):
|
||||||
f = a_episode.download(savepath=str(tmpdir))
|
f = a_episode.download(savepath=str(tmpdir))
|
||||||
assert len(f) == 1
|
assert len(f) == 1
|
||||||
|
|
||||||
with_sceen_size = a_episode.download(savepath=str(tmpdir), **{'videoResolution': '500x300'})
|
with_sceen_size = a_episode.download(savepath=str(tmpdir), **{'videoResolution': '500x300'})
|
||||||
assert len(with_sceen_size) == 1
|
assert len(with_sceen_size) == 1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_video_Show_thumbUrl(a_show):
|
def test_video_Show_thumbUrl(a_show):
|
||||||
assert 'http://138.68.157.5:32400/library/metadata/12/thumb/' in a_show.thumbUrl
|
assert 'http://138.68.157.5:32400/library/metadata/12/thumb/' in a_show.thumbUrl
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.xfail
|
@pytest.mark.xfail
|
||||||
def test_video_Show_analyze(a_show):
|
def test_video_Show_analyze(a_show):
|
||||||
show = a_show.analyze() # this isnt possble.. should it even be available?
|
show = a_show.analyze() # this isnt possble.. should it even be available?
|
||||||
|
|
||||||
|
|
||||||
def test_video_Show_markWatched(a_tv_section):
|
def test_video_Show_markWatched(a_tv_section):
|
||||||
show = a_tv_section.get("Marvel's Daredevil")
|
show = a_tv_section.get("Marvel's Daredevil")
|
||||||
show.markWatched()
|
show.markWatched()
|
||||||
|
@ -373,13 +365,12 @@ def test_video_Show_section(a_show): # BROKEN!
|
||||||
def test_video_Episode(a_show):
|
def test_video_Episode(a_show):
|
||||||
pilot = a_show.episode('Pilot')
|
pilot = a_show.episode('Pilot')
|
||||||
assert pilot == a_show.episode(season=1, episode=1)
|
assert pilot == a_show.episode(season=1, episode=1)
|
||||||
|
|
||||||
with pytest.raises(TypeError):
|
with pytest.raises(TypeError):
|
||||||
a_show.episode()
|
a_show.episode()
|
||||||
|
|
||||||
with pytest.raises(NotFound):
|
with pytest.raises(NotFound):
|
||||||
a_show.episode(season=1337, episode=1337)
|
a_show.episode(season=1337, episode=1337)
|
||||||
|
|
||||||
|
|
||||||
def test_video_Episode_analyze(a_tv_section):
|
def test_video_Episode_analyze(a_tv_section):
|
||||||
ep = a_tv_section.get("Marvel's Daredevil").episode(season=1, episode=1)
|
ep = a_tv_section.get("Marvel's Daredevil").episode(season=1, episode=1)
|
||||||
ep.analyze()
|
ep.analyze()
|
||||||
|
@ -520,52 +511,33 @@ def test_video_Season_episodes(a_show):
|
||||||
assert len(sn_eps) == 1
|
assert len(sn_eps) == 1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### MISC
|
|
||||||
def test_that_reload_return_the_same_object(pms):
|
def test_that_reload_return_the_same_object(pms):
|
||||||
# we want to check this that all the urls are correct
|
# we want to check this that all the urls are correct
|
||||||
movie_library_search = pms.library.section('Movies').search('16 Blocks')[0]
|
movie_library_search = pms.library.section('Movies').search('16 Blocks')[0]
|
||||||
movie_search = pms.search('16 Blocks')[0]
|
movie_search = pms.search('16 Blocks')[0]
|
||||||
movie_section_get = pms.library.section('Movies').get('16 Blocks')
|
movie_section_get = pms.library.section('Movies').get('16 Blocks')
|
||||||
|
|
||||||
movie_library_search_key = movie_library_search.key
|
movie_library_search_key = movie_library_search.key
|
||||||
movie_search_key = movie_search.key
|
movie_search_key = movie_search.key
|
||||||
movie_section_get_key = movie_section_get.key
|
movie_section_get_key = movie_section_get.key
|
||||||
|
|
||||||
assert movie_library_search_key == movie_library_search.reload().key == movie_search_key == movie_search.reload().key == movie_section_get_key == movie_section_get.reload().key
|
assert movie_library_search_key == movie_library_search.reload().key == movie_search_key == movie_search.reload().key == movie_section_get_key == movie_section_get.reload().key
|
||||||
|
|
||||||
tvshow_library_search = pms.library.section('TV Shows').search('The 100')[0]
|
tvshow_library_search = pms.library.section('TV Shows').search('The 100')[0]
|
||||||
tvshow_search = pms.search('The 100')[0]
|
tvshow_search = pms.search('The 100')[0]
|
||||||
tvshow_section_get = pms.library.section('TV Shows').get('The 100')
|
tvshow_section_get = pms.library.section('TV Shows').get('The 100')
|
||||||
|
|
||||||
tvshow_library_search_key = tvshow_library_search.key
|
tvshow_library_search_key = tvshow_library_search.key
|
||||||
tvshow_search_key = tvshow_search.key
|
tvshow_search_key = tvshow_search.key
|
||||||
tvshow_section_get_key = tvshow_section_get.key
|
tvshow_section_get_key = tvshow_section_get.key
|
||||||
|
|
||||||
assert tvshow_library_search_key == tvshow_library_search.reload().key == tvshow_search_key == tvshow_search.reload().key == tvshow_section_get_key == tvshow_section_get.reload().key
|
assert tvshow_library_search_key == tvshow_library_search.reload().key == tvshow_search_key == tvshow_search.reload().key == tvshow_section_get_key == tvshow_section_get.reload().key
|
||||||
|
|
||||||
season_library_search = tvshow_library_search.season(1)
|
season_library_search = tvshow_library_search.season(1)
|
||||||
season_search = tvshow_search.season(1)
|
season_search = tvshow_search.season(1)
|
||||||
season_section_get = tvshow_section_get.season(1)
|
season_section_get = tvshow_section_get.season(1)
|
||||||
|
|
||||||
season_library_search_key = season_library_search.key
|
season_library_search_key = season_library_search.key
|
||||||
season_search_key = season_search.key
|
season_search_key = season_search.key
|
||||||
season_section_get_key = season_section_get.key
|
season_section_get_key = season_section_get.key
|
||||||
|
|
||||||
assert season_library_search_key == season_library_search.reload().key == season_search_key == season_search.reload().key == season_section_get_key == season_section_get.reload().key
|
assert season_library_search_key == season_library_search.reload().key == season_search_key == season_search.reload().key == season_section_get_key == season_section_get.reload().key
|
||||||
|
|
||||||
episode_library_search = tvshow_library_search.episode(season=1, episode=1)
|
episode_library_search = tvshow_library_search.episode(season=1, episode=1)
|
||||||
episode_search = tvshow_search.episode(season=1, episode=1)
|
episode_search = tvshow_search.episode(season=1, episode=1)
|
||||||
episode_section_get = tvshow_section_get.episode(season=1, episode=1)
|
episode_section_get = tvshow_section_get.episode(season=1, episode=1)
|
||||||
|
|
||||||
episode_library_search_key = episode_library_search.key
|
episode_library_search_key = episode_library_search.key
|
||||||
episode_search_key = episode_search.key
|
episode_search_key = episode_search.key
|
||||||
episode_section_get_key = episode_section_get.key
|
episode_section_get_key = episode_section_get.key
|
||||||
|
|
||||||
assert episode_library_search_key == episode_library_search.reload().key == episode_search_key == episode_search.reload().key == episode_section_get_key == episode_section_get.reload().key
|
assert episode_library_search_key == episode_library_search.reload().key == episode_search_key == episode_search.reload().key == episode_section_get_key == episode_section_get.reload().key
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue