2022-11-25 12:20:43 -08:00
|
|
|
# 70, 73-81, 84, 88-97, 100-104
|
|
|
|
import pytest
|
|
|
|
from groove import playlist
|
2022-11-24 13:45:09 -08:00
|
|
|
|
|
|
|
|
2022-11-25 12:20:43 -08:00
|
|
|
def test_create(db):
|
|
|
|
pl = playlist.Playlist(slug='test-create-playlist', session=db, create_if_not_exists=True)
|
|
|
|
assert pl.exists
|
2022-11-24 13:45:09 -08:00
|
|
|
|
|
|
|
|
2022-11-25 12:20:43 -08:00
|
|
|
@pytest.mark.parametrize('tracks', [
|
|
|
|
('01 Guns Blazing', ),
|
|
|
|
('01 Guns Blazing', '02 UNKLE'),
|
|
|
|
])
|
|
|
|
def test_add(db, tracks):
|
|
|
|
pl = playlist.Playlist(slug='test-create-playlist', session=db, create_if_not_exists=True)
|
|
|
|
count = pl.add(tracks)
|
|
|
|
assert count == len(tracks)
|
2022-11-24 13:45:09 -08:00
|
|
|
|
|
|
|
|
2022-11-25 12:20:43 -08:00
|
|
|
def test_add_no_matches(db):
|
|
|
|
pl = playlist.Playlist(slug='playlist-one', session=db)
|
|
|
|
assert pl.add(('no match', )) == 0
|
|
|
|
|
|
|
|
|
|
|
|
def test_add_multiple_matches(db):
|
|
|
|
pl = playlist.Playlist(slug='playlist-one', session=db)
|
|
|
|
assert pl.add('UNKLE',) == 0
|
|
|
|
|
|
|
|
|
|
|
|
def test_delete(db):
|
|
|
|
pl = playlist.Playlist(slug='playlist-one', session=db)
|
|
|
|
expected = pl.record.id
|
|
|
|
assert pl.delete() == expected
|
|
|
|
assert not pl.as_dict
|
|
|
|
|
|
|
|
|
|
|
|
def test_delete_playlist_not_exist(db):
|
|
|
|
pl = playlist.Playlist(slug='playlist-doesnt-exist', session=db)
|
|
|
|
assert not pl.delete()
|
|
|
|
assert not pl.as_dict
|
|
|
|
|
|
|
|
|
|
|
|
def test_entries(db):
|
|
|
|
pl = playlist.Playlist(slug='playlist-one', session=db)
|
|
|
|
# assert twice for branch coverage of cached values
|
|
|
|
assert pl.entries
|
|
|
|
assert pl.entries
|