Fix a test in navigation

keep compat for season(int)
This commit is contained in:
Hellowlol 2020-12-30 23:58:01 +01:00
parent 5b78f6b482
commit f2e7e891cb
3 changed files with 34 additions and 33 deletions

View file

@ -2,7 +2,7 @@
import os
from urllib.parse import quote_plus, urlencode
from plexapi import media, utils, settings, library
from plexapi import library, media, settings, utils
from plexapi.base import Playable, PlexPartialObject
from plexapi.exceptions import BadRequest, NotFound
@ -500,10 +500,11 @@ class Show(Video):
:exc:`~plexapi.exceptions.BadRequest`: If title or season parameter is missing.
"""
key = '/library/metadata/%s/children' % self.ratingKey
if title:
if title and not isinstance(title, int):
return self.fetchItem(key, Season, title__iexact=title)
elif season:
return self.fetchItem(key, Season, index=season)
elif season or isinstance(title, int):
idx = season or title
return self.fetchItem(key, Season, index=idx)
raise BadRequest('Missing argument: title or season is required')
def seasons(self, **kwargs):

View file

@ -129,20 +129,19 @@ def test_myplex_inviteFriend_remove(account, plex, mocker):
secs = plex.library.sections()
ids = account._getSectionIds(plex.machineIdentifier, secs)
with mocker.patch.object(account, "_getSectionIds", return_value=ids):
with utils.callable_http_patch():
account.inviteFriend(
inv_user,
plex,
secs,
allowSync=True,
allowCameraUpload=True,
allowChannels=False,
filterMovies=vid_filter,
filterTelevision=vid_filter,
filterMusic={"label": ["foo"]},
)
mocker.patch.object(account, "_getSectionIds", return_value=ids)
with utils.callable_http_patch():
account.inviteFriend(
inv_user,
plex,
secs,
allowSync=True,
allowCameraUpload=True,
allowChannels=False,
filterMovies=vid_filter,
filterTelevision=vid_filter,
filterMusic={"label": ["foo"]},
)
assert inv_user not in [u.title for u in account.users()]
@ -157,22 +156,22 @@ def test_myplex_updateFriend(account, plex, mocker, shared_username):
user = account.user(shared_username)
ids = account._getSectionIds(plex.machineIdentifier, secs)
with mocker.patch.object(account, "_getSectionIds", return_value=ids):
with mocker.patch.object(account, "user", return_value=user):
with utils.callable_http_patch():
mocker.patch.object(account, "_getSectionIds", return_value=ids)
mocker.patch.object(account, "user", return_value=user)
with utils.callable_http_patch():
account.updateFriend(
shared_username,
plex,
secs,
allowSync=True,
removeSections=True,
allowCameraUpload=True,
allowChannels=False,
filterMovies=vid_filter,
filterTelevision=vid_filter,
filterMusic={"label": ["foo"]},
)
account.updateFriend(
shared_username,
plex,
secs,
allowSync=True,
removeSections=True,
allowCameraUpload=True,
allowChannels=False,
filterMovies=vid_filter,
filterTelevision=vid_filter,
filterMusic={"label": ["foo"]},
)
def test_myplex_createExistingUser(account, plex, shared_username):

View file

@ -9,6 +9,7 @@ def test_navigate_around_show(account, plex):
episode = show.episode("Pilot")
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 show.season(season=1) == season
assert show.season(1) == season
assert show.episode("Pilot") == episode, "Unable to get show episode:"
assert season.episode("Pilot") == episode, "Unable to get season episode:"