2017-02-02 04:47:22 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2020-04-15 18:41:15 +00:00
|
|
|
import time
|
|
|
|
|
|
|
|
import pytest
|
2017-02-02 04:10:12 +00:00
|
|
|
|
2017-02-02 04:47:22 +00:00
|
|
|
|
2017-05-13 03:25:57 +00:00
|
|
|
def _check_capabilities(client, capabilities):
|
|
|
|
supported = client.protocolCapabilities
|
|
|
|
for capability in capabilities:
|
|
|
|
if capability not in supported:
|
2020-04-15 20:53:17 +00:00
|
|
|
pytest.skip("Client %s doesnt support %s capability support %s" % (client.title, capability, supported))
|
2017-05-13 03:25:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
def _check_proxy(plex, client, proxy):
|
|
|
|
if proxy:
|
|
|
|
client.proxyThroughServer(server=plex)
|
|
|
|
|
|
|
|
|
2017-05-02 03:26:27 +00:00
|
|
|
@pytest.mark.client
|
2017-04-28 01:21:40 +00:00
|
|
|
def test_list_clients(account, plex):
|
2020-04-15 18:41:15 +00:00
|
|
|
assert account.resources(), "MyPlex is not listing any devlices."
|
|
|
|
assert account.devices(), "MyPlex is not listing any devlices."
|
|
|
|
assert plex.clients(), "PlexServer is not listing any clients."
|
2017-04-26 03:09:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.client
|
2020-04-15 18:41:15 +00:00
|
|
|
@pytest.mark.parametrize("proxy", [False, True])
|
2017-05-13 03:25:57 +00:00
|
|
|
def test_client_navigation(plex, client, episode, artist, proxy):
|
2020-04-15 18:41:15 +00:00
|
|
|
|
2020-04-15 20:53:17 +00:00
|
|
|
_check_capabilities(client, ["navigation"])
|
|
|
|
client.proxyThroughServer(proxy)
|
2017-05-13 20:13:38 +00:00
|
|
|
try:
|
2020-04-15 18:41:15 +00:00
|
|
|
print("\nclient.moveUp()")
|
|
|
|
client.moveUp()
|
|
|
|
time.sleep(0.5)
|
|
|
|
print("client.moveLeft()")
|
|
|
|
client.moveLeft()
|
|
|
|
time.sleep(0.5)
|
|
|
|
print("client.moveDown()")
|
|
|
|
client.moveDown()
|
|
|
|
time.sleep(0.5)
|
|
|
|
print("client.moveRight()")
|
|
|
|
client.moveRight()
|
|
|
|
time.sleep(0.5)
|
|
|
|
print("client.select()")
|
|
|
|
client.select()
|
|
|
|
time.sleep(3)
|
|
|
|
print("client.goBack()")
|
|
|
|
client.goBack()
|
|
|
|
time.sleep(1)
|
|
|
|
print("client.goToMedia(episode)")
|
|
|
|
client.goToMedia(episode)
|
|
|
|
time.sleep(5)
|
|
|
|
print("client.goToMedia(artist)")
|
|
|
|
client.goToMedia(artist)
|
|
|
|
time.sleep(5)
|
|
|
|
# print('client.contextMenu'); client.contextMenu(); time.sleep(3) # socket.timeout
|
2017-05-13 20:13:38 +00:00
|
|
|
finally:
|
2020-04-15 18:41:15 +00:00
|
|
|
print("client.goToHome()")
|
|
|
|
client.goToHome()
|
|
|
|
time.sleep(2)
|
2017-04-26 03:09:37 +00:00
|
|
|
|
|
|
|
|
2017-05-13 03:25:57 +00:00
|
|
|
@pytest.mark.client
|
2020-04-15 18:41:15 +00:00
|
|
|
@pytest.mark.parametrize("proxy", [False, True])
|
2020-04-15 20:53:17 +00:00
|
|
|
def test_client_playback(plex, client, movies, proxy):
|
2020-04-15 18:41:15 +00:00
|
|
|
|
2020-04-15 20:53:17 +00:00
|
|
|
movie = movies.get("Big buck bunny")
|
2020-04-15 18:41:15 +00:00
|
|
|
|
2020-04-15 20:53:17 +00:00
|
|
|
_check_capabilities(client, ["playback"])
|
2020-04-15 18:41:15 +00:00
|
|
|
client.proxyThroughServer(proxy)
|
|
|
|
|
2017-05-13 03:25:57 +00:00
|
|
|
try:
|
|
|
|
# Need a movie with subtitles
|
2020-04-15 18:41:15 +00:00
|
|
|
mtype = "video"
|
|
|
|
subs = [
|
|
|
|
stream for stream in movie.subtitleStreams() if stream.language == "English"
|
|
|
|
]
|
2020-04-15 20:53:17 +00:00
|
|
|
print("client.playMedia(%s)" % movie.title)
|
2020-04-15 18:41:15 +00:00
|
|
|
client.playMedia(movie)
|
|
|
|
time.sleep(5)
|
2020-04-15 20:53:17 +00:00
|
|
|
print("client.pause(%s)" % mtype)
|
2020-04-15 18:41:15 +00:00
|
|
|
client.pause(mtype)
|
|
|
|
time.sleep(2)
|
2020-04-15 20:53:17 +00:00
|
|
|
print("client.stepForward(%s)" % mtype)
|
2020-04-15 18:41:15 +00:00
|
|
|
client.stepForward(mtype)
|
|
|
|
time.sleep(5)
|
2020-04-15 20:53:17 +00:00
|
|
|
print("client.play(%s)" % mtype)
|
2020-04-15 18:41:15 +00:00
|
|
|
client.play(mtype)
|
|
|
|
time.sleep(3)
|
2020-04-15 20:53:17 +00:00
|
|
|
print("client.stepBack(%s)" % mtype)
|
2020-04-15 18:41:15 +00:00
|
|
|
client.stepBack(mtype)
|
|
|
|
time.sleep(5)
|
2020-04-15 20:53:17 +00:00
|
|
|
print("client.play(%s)" % mtype)
|
2020-04-15 18:41:15 +00:00
|
|
|
client.play(mtype)
|
|
|
|
time.sleep(3)
|
2020-04-15 20:53:17 +00:00
|
|
|
print("client.seekTo(1*60*1000)")
|
|
|
|
client.seekTo(1 * 60 * 1000)
|
2020-04-15 18:41:15 +00:00
|
|
|
time.sleep(5)
|
|
|
|
print("client.setSubtitleStream(0)")
|
|
|
|
client.setSubtitleStream(0, mtype)
|
|
|
|
time.sleep(10)
|
2020-04-15 20:53:17 +00:00
|
|
|
if subs:
|
|
|
|
print("client.setSubtitleStream(subs[0])")
|
|
|
|
client.setSubtitleStream(subs[0].id, mtype)
|
2020-04-15 18:41:15 +00:00
|
|
|
time.sleep(10)
|
2020-04-15 20:53:17 +00:00
|
|
|
print("client.stop(%s)" % mtype)
|
2020-04-15 18:41:15 +00:00
|
|
|
client.stop(mtype)
|
|
|
|
time.sleep(1)
|
2017-05-13 03:25:57 +00:00
|
|
|
finally:
|
2020-04-15 18:41:15 +00:00
|
|
|
print("movie.markWatched")
|
|
|
|
movie.markWatched()
|
|
|
|
time.sleep(2)
|
2017-05-13 03:25:57 +00:00
|
|
|
|
|
|
|
|
2017-04-26 03:09:37 +00:00
|
|
|
@pytest.mark.client
|
2020-04-15 18:41:15 +00:00
|
|
|
@pytest.mark.parametrize("proxy", [False, True])
|
2020-04-15 20:53:17 +00:00
|
|
|
def test_client_timeline(plex, client, movies, proxy):
|
|
|
|
|
|
|
|
movie = movies.get("Big buck bunny")
|
|
|
|
_check_capabilities(client, ["timeline"])
|
2017-05-13 20:13:38 +00:00
|
|
|
_check_proxy(plex, client, proxy)
|
|
|
|
try:
|
|
|
|
# Note: We noticed the isPlaying flag could take up to a full
|
|
|
|
# 30 seconds to be updated, hence the long sleeping.
|
2020-04-15 20:53:17 +00:00
|
|
|
mtype= "video"
|
|
|
|
client.stop(mtype)
|
2017-05-13 20:13:38 +00:00
|
|
|
assert client.isPlayingMedia() is False
|
2020-04-15 18:41:15 +00:00
|
|
|
print("client.playMedia(movie)")
|
|
|
|
client.playMedia(movie)
|
2020-04-15 20:53:17 +00:00
|
|
|
time.sleep(10)
|
2017-05-13 20:13:38 +00:00
|
|
|
assert client.isPlayingMedia() is True
|
2020-04-15 20:53:17 +00:00
|
|
|
print("client.stop(%s)" % mtype)
|
2020-04-15 18:41:15 +00:00
|
|
|
client.stop(mtype)
|
2020-04-15 20:53:17 +00:00
|
|
|
time.sleep(10)
|
2017-05-13 20:13:38 +00:00
|
|
|
assert client.isPlayingMedia() is False
|
|
|
|
finally:
|
2020-04-15 18:41:15 +00:00
|
|
|
print("movie.markWatched()")
|
|
|
|
movie.markWatched()
|
|
|
|
time.sleep(2)
|