Fix playlist tests

This commit is contained in:
JonnyWong16 2020-12-24 09:21:29 -08:00
parent 2765bee2b3
commit 810c5566c3
No known key found for this signature in database
GPG key ID: B1F1F9807184697A
2 changed files with 7 additions and 4 deletions

View file

@ -98,14 +98,14 @@ class Playlist(PlexPartialObject, Playable):
title (str): Title of the item to return.
"""
for item in self.items():
if item.title.lower() == title:
if item.title.lower() == title.lower():
return item
raise NotFound('Item with title "%s" not found in the playlist')
raise NotFound('Item with title "%s" not found in the playlist' % title)
def items(self):
""" Returns a list of all items in the playlist. """
if self._items is None:
key = '/playlist/%s/items' % self.ratingKey
key = '/playlists/%s/items' % self.ratingKey
items = self.fetchItems(key)
self._items = items
return self._items

View file

@ -2,6 +2,7 @@
import time
import pytest
from plexapi.exceptions import NotFound
def test_create_playlist(plex, show):
@ -51,7 +52,7 @@ def test_create_playlist(plex, show):
def test_playlist_item(plex, show):
title = 'test_create_playlist_item_show'
title = 'test_playlist_item'
episodes = show.episodes()
try:
playlist = plex.createPlaylist(title, episodes[:3])
@ -60,6 +61,8 @@ def test_playlist_item(plex, show):
item2 = playlist.get("Winter Is Coming")
assert item2 in playlist.items()
assert item1 == item2
with pytest.raises(NotFound):
playlist.item("Does not exist")
finally:
playlist.delete()