diff --git a/tests/conftest.py b/tests/conftest.py index 9dfde0b29..81b99252e 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -450,7 +450,7 @@ def detect_color_image(file, thumb_size=150, MSE_cutoff=22, adjust_color_bias=Tr if adjust_color_bias: bias = ImageStat.Stat(thumb).mean[:3] bias = [b - sum(bias) / 3 for b in bias] - for pixel in thumb.getdata(): + for pixel in thumb.get_flattened_data(): mu = sum(pixel) / 3 sse += sum( (pixel[i] - mu - bias[i]) * (pixel[i] - mu - bias[i]) for i in [0, 1, 2] diff --git a/tests/test_myplex.py b/tests/test_myplex.py index 7dc15e414..6059251ba 100644 --- a/tests/test_myplex.py +++ b/tests/test_myplex.py @@ -2,8 +2,8 @@ import pytest from plexapi.exceptions import BadRequest, NotFound, Unauthorized -from plexapi.myplex import MyPlexAccount, MyPlexInvite, MyPlexJWTLogin -from plexapi.utils import createMyPlexDevice +from plexapi.myplex import MyPlexAccount, MyPlexInvite, MyPlexPinLogin, MyPlexJWTLogin +from plexapi.utils import generateUUID from . import conftest as utils from .payloads import MYPLEX_INVITE @@ -371,14 +371,19 @@ def test_myplex_ping(account): def test_myplex_jwt_login(account, tmp_path, monkeypatch): # Create a new MyPlexDevice for JWT tests - device = createMyPlexDevice(account=account) + clientIdentifier = generateUUID() + headers = {'X-Plex-Client-Identifier': clientIdentifier} + pinlogin = MyPlexPinLogin(headers=headers) + pinlogin.run() + account.link(pinlogin.pin) + pinlogin.waitForLogin() privkey = tmp_path / 'private.key' pubkey = tmp_path / 'public.key' jwtlogin = MyPlexJWTLogin( - headers={'X-Plex-Client-Identifier': device.clientIdentifier}, - token=device.token, + headers=headers, + token=pinlogin.token, scopes=['username', 'email', 'friendly_name'] ) jwtlogin.generateKeypair(keyfiles=(privkey, pubkey), overwrite=True) @@ -391,7 +396,7 @@ def test_myplex_jwt_login(account, tmp_path, monkeypatch): assert new_account.username == account.username jwtlogin = MyPlexJWTLogin( - headers={'X-Plex-Client-Identifier': device.clientIdentifier}, + headers=headers, jwtToken=jwtToken, keypair=(privkey, pubkey), scopes=['username', 'email', 'friendly_name'] @@ -411,4 +416,4 @@ def test_myplex_jwt_login(account, tmp_path, monkeypatch): with pytest.raises(jwt.InvalidSignatureError): jwtlogin.decodePlexJWT() - device.delete() + account.device(clientId=clientIdentifier).delete() diff --git a/tests/test_video.py b/tests/test_video.py index 410d96d3a..24fdac8de 100644 --- a/tests/test_video.py +++ b/tests/test_video.py @@ -442,6 +442,7 @@ def test_video_Movie_upload_select_remove_subtitle(movie, subtitle): pass +@pytest.mark.xfail(reason="Plex's OpenSubtitles times out occasionally") def test_video_Movie_on_demand_subtitles(movie, account): movie_subtitles = movie.subtitleStreams() subtitles = movie.searchSubtitles()