mirror of
https://github.com/pkkid/python-plexapi
synced 2024-11-22 11:43:13 +00:00
Update test_playlist
This commit is contained in:
parent
7bb39aa05c
commit
5278d583bc
2 changed files with 33 additions and 38 deletions
|
@ -99,7 +99,7 @@ def episode(show):
|
|||
|
||||
@pytest.fixture()
|
||||
def photoalbum(photos):
|
||||
return photos.get('photo_album1')
|
||||
return photos.get('Cats')
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
|
|
|
@ -2,52 +2,44 @@
|
|||
import pytest, time
|
||||
|
||||
|
||||
def test_create_playlist(pms, a_show):
|
||||
def test_create_playlist(plex, show):
|
||||
# create the playlist
|
||||
title = 'test_create_playlist_a_show'
|
||||
title = 'test_create_playlist_show'
|
||||
#print('Creating playlist %s..' % title)
|
||||
episodes = a_show.episodes()
|
||||
playlist = pms.createPlaylist(title, episodes[:3])
|
||||
episodes = show.episodes()
|
||||
playlist = plex.createPlaylist(title, episodes[:3])
|
||||
try:
|
||||
items = playlist.items()
|
||||
#log(4, 'Title: %s' % playlist.title)
|
||||
#log(4, 'Items: %s' % items)
|
||||
#log(4, 'Duration: %s min' % int(playlist.duration / 60000.0))
|
||||
# Test create playlist
|
||||
assert playlist.title == title, 'Playlist not created successfully.'
|
||||
assert len(items) == 3, 'Playlist does not contain 3 items.'
|
||||
assert items[0].ratingKey == episodes[0].ratingKey, 'Items not in proper order [0a].'
|
||||
assert items[1].ratingKey == episodes[1].ratingKey, 'Items not in proper order [1a].'
|
||||
assert items[2].ratingKey == episodes[2].ratingKey, 'Items not in proper order [2a].'
|
||||
# move items around (b)
|
||||
#print('Testing move items..')
|
||||
# Test move items around (b)
|
||||
playlist.moveItem(items[1])
|
||||
items = playlist.items()
|
||||
assert items[0].ratingKey == episodes[1].ratingKey, 'Items not in proper order [0b].'
|
||||
assert items[1].ratingKey == episodes[0].ratingKey, 'Items not in proper order [1b].'
|
||||
assert items[2].ratingKey == episodes[2].ratingKey, 'Items not in proper order [2b].'
|
||||
# move items around (c)
|
||||
# Test move items around (c)
|
||||
playlist.moveItem(items[0], items[1])
|
||||
items = playlist.items()
|
||||
assert items[0].ratingKey == episodes[0].ratingKey, 'Items not in proper order [0c].'
|
||||
assert items[1].ratingKey == episodes[1].ratingKey, 'Items not in proper order [1c].'
|
||||
assert items[2].ratingKey == episodes[2].ratingKey, 'Items not in proper order [2c].'
|
||||
# add an item
|
||||
#print('Testing add item: %s' % episodes[3])
|
||||
# Test add item
|
||||
playlist.addItems(episodes[3])
|
||||
items = playlist.items()
|
||||
#log(4, '4th Item: %s' % items[3])
|
||||
assert items[3].ratingKey == episodes[3].ratingKey, 'Missing added item: %s' % episodes[3]
|
||||
# add two items
|
||||
#print('Testing add item: %s' % episodes[4:6])
|
||||
# Test add two items
|
||||
playlist.addItems(episodes[4:6])
|
||||
items = playlist.items()
|
||||
#log(4, '5th+ Items: %s' % items[4:])
|
||||
assert items[4].ratingKey == episodes[4].ratingKey, 'Missing added item: %s' % episodes[4]
|
||||
assert items[5].ratingKey == episodes[5].ratingKey, 'Missing added item: %s' % episodes[5]
|
||||
assert len(items) == 6, 'Playlist should have 6 items, %s found' % len(items)
|
||||
# remove item
|
||||
# Test remove item
|
||||
toremove = items[3]
|
||||
#print('Testing remove item: %s' % toremove)
|
||||
playlist.removeItem(toremove)
|
||||
items = playlist.items()
|
||||
assert toremove not in items, 'Removed item still in playlist: %s' % items[3]
|
||||
|
@ -57,41 +49,44 @@ def test_create_playlist(pms, a_show):
|
|||
|
||||
|
||||
@pytest.mark.req_client
|
||||
def test_playlist_play(pms):
|
||||
def test_playlist_play(plex):
|
||||
client = getclient(CONFIG.client, CONFIG.client_baseurl, plex)
|
||||
artist = plex.library.section(CONFIG.audio_section).get(CONFIG.audio_artist)
|
||||
album = artist.album(CONFIG.audio_album)
|
||||
pl_name = 'test_play_playlist'
|
||||
playlist = plex.createPlaylist(pl_name, album)
|
||||
try:
|
||||
playlist_name = 'test_play_playlist'
|
||||
playlist = plex.createPlaylist(playlist_name, album)
|
||||
client.playMedia(playlist); time.sleep(5)
|
||||
client.stop('music'); time.sleep(1)
|
||||
finally:
|
||||
playlist.delete()
|
||||
assert pl_name not in [i.title for i in pms.playlists()]
|
||||
assert playlist_name not in [i.title for i in plex.playlists()]
|
||||
|
||||
|
||||
def test_playlist_photos(pms, a_photo_album):
|
||||
album = a_photo_album
|
||||
def test_playlist_photos(plex, photoalbum):
|
||||
album = photoalbum
|
||||
photos = album.photos()
|
||||
pl_name = 'test_playlist_photos'
|
||||
playlist = pms.createPlaylist(pl_name, photos)
|
||||
try:
|
||||
assert len(playlist.items()) == 4
|
||||
playlist_name = 'test_playlist_photos'
|
||||
playlist = plex.createPlaylist(playlist_name, photos)
|
||||
assert len(playlist.items()) >= 1
|
||||
finally:
|
||||
playlist.delete()
|
||||
assert pl_name not in [i.title for i in pms.playlists()]
|
||||
assert playlist_name not in [i.title for i in plex.playlists()]
|
||||
|
||||
|
||||
def test_playlist_playQueue(pms):
|
||||
pl = pms.playlists()[0]
|
||||
pq = pl.playQueue(**dict(shuffle=1))
|
||||
assert 'shuffle=1' in pq._initpath
|
||||
assert pq.playQueueShuffled is True
|
||||
def test_playlist_playQueue(plex, album):
|
||||
try:
|
||||
playlist = plex.createPlaylist('test_playlist', album)
|
||||
playqueue = playlist.playQueue(**dict(shuffle=1))
|
||||
assert 'shuffle=1' in playqueue._initpath
|
||||
assert playqueue.playQueueShuffled is True
|
||||
finally:
|
||||
playlist.delete()
|
||||
|
||||
|
||||
@pytest.mark.req_client
|
||||
def _test_play_photos(account, plex):
|
||||
def test_play_photos(account, plex):
|
||||
client = getclient('iphone-mike', CONFIG.client_baseurl, plex)
|
||||
photosection = plex.library.section(CONFIG.photo_section)
|
||||
album = photosection.get(CONFIG.photo_album)
|
||||
|
@ -101,9 +96,9 @@ def _test_play_photos(account, plex):
|
|||
time.sleep(2)
|
||||
|
||||
|
||||
def test_play_queues(pms):
|
||||
episode = pms.library.section('TV Shows').get('the 100').get('Pilot')
|
||||
playqueue = pms.createPlayQueue(episode)
|
||||
def test_playqueues(plex):
|
||||
episode = plex.library.section('TV Shows').get('the 100').get('Pilot')
|
||||
playqueue = plex.createPlayQueue(episode)
|
||||
assert len(playqueue.items) == 1, 'No items in play queue.'
|
||||
assert playqueue.items[0].title == episode.title, 'Wrong show queued.'
|
||||
assert playqueue.playQueueID, 'Play queue ID not set.'
|
||||
|
|
Loading…
Reference in a new issue