def setUp(self): super(BrowseTestCase, self).setUp() empty = Folder() empty.root = True empty.name = 'Empty root' empty.path = '/tmp' self.store.add(empty) root = Folder() root.root = True root.name = 'Root folder' root.path = 'tests/assets' self.store.add(root) for letter in 'ABC': folder = Folder() folder.name = letter + 'rtist' folder.path = 'tests/assets/{}rtist'.format(letter) folder.parent = root artist = Artist() artist.name = letter + 'rtist' for lether in 'AB': afolder = Folder() afolder.name = letter + lether + 'lbum' afolder.path = 'tests/assets/{0}rtist/{0}{1}lbum'.format( letter, lether) afolder.parent = folder album = Album() album.name = letter + lether + 'lbum' album.artist = artist for num, song in enumerate(['One', 'Two', 'Three']): track = Track() track.disc = 1 track.number = num track.title = song track.duration = 2 track.album = album track.artist = artist track.bitrate = 320 track.path = 'tests/assets/{0}rtist/{0}{1}lbum/{2}'.format( letter, lether, song) track.content_type = 'audio/mpeg' track.last_modification = 0 track.root_folder = root track.folder = afolder self.store.add(track) self.store.commit() self.assertEqual(self.store.find(Folder).count(), 11) self.assertEqual( self.store.find(Folder, Folder.root == True).count(), 2) self.assertEqual(self.store.find(Artist).count(), 3) self.assertEqual(self.store.find(Album).count(), 6) self.assertEqual(self.store.find(Track).count(), 18)
def setUp(self): super(AlbumSongsTestCase, self).setUp() folder = Folder() folder.name = 'Root' folder.root = True folder.path = 'tests/assets' artist = Artist() artist.name = 'Artist' album = Album() album.name = 'Album' album.artist = artist track = Track() track.title = 'Track' track.album = album track.artist = artist track.disc = 1 track.number = 1 track.path = 'tests/assets/empty' track.folder = folder track.root_folder = folder track.duration = 2 track.bitrate = 320 track.content_type = 'audio/mpeg' track.last_modification = 0 self.store.add(track) self.store.commit()
def test_get_album_list2(self): self._make_request("getAlbumList2", error=10) self._make_request("getAlbumList2", {"type": "void"}, error=0) self._make_request( "getAlbumList2", {"type": "random", "size": "size_t"}, error=0 ) self._make_request( "getAlbumList2", {"type": "newest", "offset": "&v + 2"}, error=0 ) types = [ "random", "newest", "frequent", "recent", "starred", "alphabeticalByName", "alphabeticalByArtist", ] for t in types: self._make_request( "getAlbumList2", {"type": t}, tag="albumList2", skip_post=True ) rv, child = self._make_request( "getAlbumList2", {"type": "random"}, tag="albumList2", skip_post=True ) with db_session: Track.get().delete() Album.get().delete() rv, child = self._make_request( "getAlbumList2", {"type": "random"}, tag="albumList2" ) self.assertEqual(len(child), 0)
def setUp(self): super(MediaTestCase, self).setUp() self.folder = Folder() self.folder.name = 'Root' self.folder.path = os.path.abspath('tests/assets') self.folder.root = True self.folder.has_cover_art = True # 420x420 PNG artist = Artist() artist.name = 'Artist' album = Album() album.artist = artist album.name = 'Album' self.track = Track() self.track.title = '23bytes' self.track.number = 1 self.track.disc = 1 self.track.artist = artist self.track.album = album self.track.path = os.path.abspath('tests/assets/23bytes') self.track.root_folder = self.folder self.track.folder = self.folder self.track.duration = 2 self.track.bitrate = 320 self.track.content_type = 'audio/mpeg' self.track.last_modification = 0 self.store.add(self.track) self.store.commit()
def setUp(self): super(PlaylistTestCase, self).setUp() root = Folder() root.root = True root.name = 'Root folder' root.path = 'tests/assets' self.store.add(root) artist = Artist() artist.name = 'Artist' album = Album() album.name = 'Album' album.artist = artist songs = {} for num, song in enumerate(['One', 'Two', 'Three', 'Four']): track = Track() track.disc = 1 track.number = num track.title = song track.duration = 2 track.album = album track.artist = artist track.bitrate = 320 track.path = 'tests/assets/empty' track.content_type = 'audio/mpeg' track.last_modification = 0 track.root_folder = root track.folder = root self.store.add(track) songs[song] = track users = {u.name: u for u in self.store.find(User)} playlist = Playlist() playlist.user = users['alice'] playlist.name = "Alice's" playlist.add(songs['One']) playlist.add(songs['Three']) self.store.add(playlist) playlist = Playlist() playlist.user = users['alice'] playlist.public = True playlist.name = "Alice's public" playlist.add(songs['One']) playlist.add(songs['Two']) self.store.add(playlist) playlist = Playlist() playlist.user = users['bob'] playlist.name = "Bob's" playlist.add(songs['Two']) playlist.add(songs['Four']) self.store.add(playlist) self.store.commit()
def setUp(self): super(MediaTestCase, self).setUp() self.folder = Folder() self.folder.name = 'Root' self.folder.path = os.path.abspath('tests/assets') self.folder.root = True self.folder.has_cover_art = True # 420x420 PNG artist = Artist() artist.name = 'Artist' album = Album() album.artist = artist album.name = 'Album' self.track = Track() self.track.title = '23bytes' self.track.number = 1 self.track.disc = 1 self.track.artist = artist self.track.album = album self.track.path = os.path.abspath('tests/assets/23bytes') self.track.root_folder = self.folder self.track.folder = self.folder self.track.duration = 2 self.track.bitrate = 320 self.track.content_type = 'audio/mpeg' self.track.last_modification = 0 self.store.add(self.track) self.store.commit()
def test_get_album_list2(self): self._make_request('getAlbumList2', error=10) self._make_request('getAlbumList2', {'type': 'void'}, error=0) self._make_request('getAlbumList2', { 'type': 'random', 'size': 'size_t' }, error=0) self._make_request('getAlbumList2', { 'type': 'newest', 'offset': '&v + 2' }, error=0) types = [ 'random', 'newest', 'frequent', 'recent', 'starred', 'alphabeticalByName', 'alphabeticalByArtist' ] for t in types: self._make_request('getAlbumList2', {'type': t}, tag='albumList2', skip_post=True) rv, child = self._make_request('getAlbumList2', {'type': 'random'}, tag='albumList2', skip_post=True) with db_session: Track.get().delete() Album.get().delete() rv, child = self._make_request('getAlbumList2', {'type': 'random'}, tag='albumList2') self.assertEqual(len(child), 0)
def setUp(self): super(PlaylistTestCase, self).setUp() root = Folder() root.root = True root.name = 'Root folder' root.path = 'tests/assets' self.store.add(root) artist = Artist() artist.name = 'Artist' album = Album() album.name = 'Album' album.artist = artist songs = {} for num, song in enumerate([ 'One', 'Two', 'Three', 'Four' ]): track = Track() track.disc = 1 track.number = num track.title = song track.duration = 2 track.album = album track.artist = artist track.bitrate = 320 track.path = 'tests/assets/empty' track.content_type = 'audio/mpeg' track.last_modification = 0 track.root_folder = root track.folder = root self.store.add(track) songs[song] = track users = { u.name: u for u in self.store.find(User) } playlist = Playlist() playlist.user = users['alice'] playlist.name = "Alice's" playlist.add(songs['One']) playlist.add(songs['Three']) self.store.add(playlist) playlist = Playlist() playlist.user = users['alice'] playlist.public = True playlist.name = "Alice's public" playlist.add(songs['One']) playlist.add(songs['Two']) self.store.add(playlist) playlist = Playlist() playlist.user = users['bob'] playlist.name = "Bob's" playlist.add(songs['Two']) playlist.add(songs['Four']) self.store.add(playlist) self.store.commit()
def setUp(self): super(BrowseTestCase, self).setUp() empty = Folder() empty.root = True empty.name = 'Empty root' empty.path = '/tmp' self.store.add(empty) root = Folder() root.root = True root.name = 'Root folder' root.path = 'tests/assets' self.store.add(root) for letter in 'ABC': folder = Folder() folder.name = letter + 'rtist' folder.path = 'tests/assets/{}rtist'.format(letter) folder.parent = root artist = Artist() artist.name = letter + 'rtist' for lether in 'AB': afolder = Folder() afolder.name = letter + lether + 'lbum' afolder.path = 'tests/assets/{0}rtist/{0}{1}lbum'.format(letter, lether) afolder.parent = folder album = Album() album.name = letter + lether + 'lbum' album.artist = artist for num, song in enumerate([ 'One', 'Two', 'Three' ]): track = Track() track.disc = 1 track.number = num track.title = song track.duration = 2 track.album = album track.artist = artist track.bitrate = 320 track.path = 'tests/assets/{0}rtist/{0}{1}lbum/{2}'.format(letter, lether, song) track.content_type = 'audio/mpeg' track.last_modification = 0 track.root_folder = root track.folder = afolder self.store.add(track) self.store.commit() self.assertEqual(self.store.find(Folder).count(), 11) self.assertEqual(self.store.find(Folder, Folder.root == True).count(), 2) self.assertEqual(self.store.find(Artist).count(), 3) self.assertEqual(self.store.find(Album).count(), 6) self.assertEqual(self.store.find(Track).count(), 18)
def __find_album(self, artist, album): ar = self.__find_artist(artist) al = ar.albums.find(name = album).one() if al: return al al = Album() al.name = album al.artist = ar self.__store.add(al) self.__added_albums += 1 return al
def __find_album(self, artist, album): ar = self.__find_artist(artist) al = ar.albums.find(name=album).one() if al: return al al = Album() al.name = album al.artist = ar self.__store.add(al) self.__added_albums += 1 return al
def setUp(self): super().setUp() with db_session: Folder(root=True, name="Empty root", path="/tmp") root = Folder(root=True, name="Root folder", path="tests/assets") for letter in "ABC": folder = Folder( name=letter + "rtist", path="tests/assets/{}rtist".format(letter), parent=root, ) artist = Artist(name=letter + "rtist") for lether in "AB": afolder = Folder( name=letter + lether + "lbum", path="tests/assets/{0}rtist/{0}{1}lbum".format( letter, lether), parent=folder, ) album = Album(name=letter + lether + "lbum", artist=artist) for num, song in enumerate(["One", "Two", "Three"]): Track( disc=1, number=num, title=song, duration=2, album=album, artist=artist, genre="Music!", bitrate=320, path="tests/assets/{0}rtist/{0}{1}lbum/{2}".format( letter, lether, song), last_modification=0, root_folder=root, folder=afolder, ) self.assertEqual(Folder.select().count(), 11) self.assertEqual(Folder.select(lambda f: f.root).count(), 2) self.assertEqual(Artist.select().count(), 3) self.assertEqual(Album.select().count(), 6) self.assertEqual(Track.select().count(), 18)
def setUp(self): super().setUp() with db_session: root = Folder(name="Root", root=True, path="tests") folder = Folder(name="Folder", path="tests/assets", parent=root) artist = Artist(name="Artist") album = Album(name="Album", artist=artist) # Populate folder ids root = Folder.get(name="Root") folder = Folder.get(name="Folder") track = Track( title="Track", album=album, artist=artist, disc=1, number=1, path="tests/assets/empty", folder=folder, root_folder=root, duration=2, bitrate=320, last_modification=0, ) self.folderid = folder.id self.artistid = artist.id self.albumid = album.id self.trackid = track.id self.user = User.get(name="alice")
def setUp(self): super(AnnotationTestCase, self).setUp() with db_session: root = Folder(name='Root', root=True, path='tests') folder = Folder(name='Folder', path='tests/assets', parent=root) artist = Artist(name='Artist') album = Album(name='Album', artist=artist) track = Track(title='Track', album=album, artist=artist, disc=1, number=1, path='tests/assets/empty', folder=folder, root_folder=root, duration=2, bitrate=320, content_type='audio/mpeg', last_modification=0) self.folderid = folder.id self.artistid = artist.id self.albumid = album.id self.trackid = track.id self.user = User.get(name='alice')
def setUp(self): super(PlaylistTestCase, self).setUp() with db_session: folder = Folder(name="Root", path="tests/assets", root=True) artist = Artist(name="Artist!") album = Album(name="Album!", artist=artist) track = Track( path="tests/assets/23bytes", title="23bytes", artist=artist, album=album, folder=folder, root_folder=folder, duration=2, disc=1, number=1, bitrate=320, last_modification=0, ) playlist = Playlist(name="Playlist!", user=User.get(name="alice")) for _ in range(4): playlist.add(track) self.playlistid = playlist.id
def setUp(self): super().setUp() with db_session: folder = Folder( name="Root", path=os.path.abspath("tests/assets"), root=True, cover_art="cover.jpg", ) self.folderid = folder.id artist = Artist(name="Artist") album = Album(artist=artist, name="Album") Track( title="23bytes", number=1, disc=1, artist=artist, album=album, path=os.path.abspath("tests/assets/23bytes"), root_folder=folder, folder=folder, duration=2, bitrate=320, last_modification=0, )
def setUp(self): super(MediaTestCase, self).setUp() with db_session: folder = Folder(name='Root', path=os.path.abspath('tests/assets'), root=True, cover_art='cover.jpg') self.folderid = folder.id artist = Artist(name='Artist') album = Album(artist=artist, name='Album') track = Track(title='23bytes', number=1, disc=1, artist=artist, album=album, path=os.path.abspath('tests/assets/23bytes'), root_folder=folder, folder=folder, duration=2, bitrate=320, content_type='audio/mpeg', last_modification=0) self.trackid = track.id
def test_get_album_list2(self): self._make_request('getAlbumList2', error = 10) self._make_request('getAlbumList2', { 'type': 'void' }, error = 0) self._make_request('getAlbumList2', { 'type': 'random', 'size': 'size_t' }, error = 0) self._make_request('getAlbumList2', { 'type': 'newest', 'offset': '&v + 2' }, error = 0) types = [ 'random', 'newest', 'frequent', 'recent', 'starred', 'alphabeticalByName', 'alphabeticalByArtist' ] for t in types: self._make_request('getAlbumList2', { 'type': t }, tag = 'albumList2', skip_post = True) rv, child = self._make_request('getAlbumList2', { 'type': 'random' }, tag = 'albumList2', skip_post = True) with db_session: Track.get().delete() Album.get().delete() rv, child = self._make_request('getAlbumList2', { 'type': 'random' }, tag = 'albumList2') self.assertEqual(len(child), 0)
def setUp(self): super(BrowseTestCase, self).setUp() with db_session: Folder(root = True, name = 'Empty root', path = '/tmp') root = Folder(root = True, name = 'Root folder', path = 'tests/assets') for letter in 'ABC': folder = Folder( name = letter + 'rtist', path = 'tests/assets/{}rtist'.format(letter), parent = root ) artist = Artist(name = letter + 'rtist') for lether in 'AB': afolder = Folder( name = letter + lether + 'lbum', path = 'tests/assets/{0}rtist/{0}{1}lbum'.format(letter, lether), parent = folder ) album = Album(name = letter + lether + 'lbum', artist = artist) for num, song in enumerate([ 'One', 'Two', 'Three' ]): track = Track( disc = 1, number = num, title = song, duration = 2, album = album, artist = artist, bitrate = 320, path = 'tests/assets/{0}rtist/{0}{1}lbum/{2}'.format(letter, lether, song), last_modification = 0, root_folder = root, folder = afolder ) self.assertEqual(Folder.select().count(), 11) self.assertEqual(Folder.select(lambda f: f.root).count(), 2) self.assertEqual(Artist.select().count(), 3) self.assertEqual(Album.select().count(), 6) self.assertEqual(Track.select().count(), 18)
def setUp(self): super(AnnotationTestCase, self).setUp() root = Folder() root.name = 'Root' root.root = True root.path = 'tests/assets' folder = Folder() folder.name = 'Folder' folder.path = 'tests/assets' folder.parent = root artist = Artist() artist.name = 'Artist' album = Album() album.name = 'Album' album.artist = artist track = Track() track.title = 'Track' track.album = album track.artist = artist track.disc = 1 track.number = 1 track.path = 'tests/assets/empty' track.folder = folder track.root_folder = root track.duration = 2 track.bitrate = 320 track.content_type = 'audio/mpeg' track.last_modification = 0 self.store.add(track) self.store.commit() self.folder = folder self.artist = artist self.album = album self.track = track self.user = self.store.find(User, User.name == 'alice').one()
def setUp(self): super(PlaylistTestCase, self).setUp() folder = Folder() folder.name = 'Root' folder.path = 'tests/assets' folder.root = True artist = Artist() artist.name = 'Artist!' album = Album() album.name = 'Album!' album.artist = artist track = Track() track.path = 'tests/assets/23bytes' track.title = '23bytes' track.artist = artist track.album = album track.folder = folder track.root_folder = folder track.duration = 2 track.disc = 1 track.number = 1 track.content_type = 'audio/mpeg' track.bitrate = 320 track.last_modification = 0 playlist = Playlist() playlist.name = 'Playlist!' playlist.user = self.store.find(User, User.name == 'alice').one() for _ in range(4): playlist.add(track) self.store.add(track) self.store.add(playlist) self.store.commit() self.playlist = playlist
def setUp(self): super(PlaylistTestCase, self).setUp() folder = Folder() folder.name = 'Root' folder.path = 'tests/assets' folder.root = True artist = Artist() artist.name = 'Artist!' album = Album() album.name = 'Album!' album.artist = artist track = Track() track.path = 'tests/assets/23bytes' track.title = '23bytes' track.artist = artist track.album = album track.folder = folder track.root_folder = folder track.duration = 2 track.disc = 1 track.number = 1 track.content_type = 'audio/mpeg' track.bitrate = 320 track.last_modification = 0 playlist = Playlist() playlist.name = 'Playlist!' playlist.user = self.store.find(User, User.name == 'alice').one() for _ in range(4): playlist.add(track) self.store.add(track) self.store.add(playlist) self.store.commit() self.playlist = playlist
def setUp(self): super().setUp() with db_session: folder = Folder( name="Root", path=os.path.abspath("tests/assets"), root=True, cover_art="cover.jpg", ) folder = Folder.get(name="Root") self.folderid = folder.id artist = Artist(name="Artist") album = Album(artist=artist, name="Album") track = Track( title="23bytes", number=1, disc=1, artist=artist, album=album, path=os.path.abspath("tests/assets/23bytes"), root_folder=folder, folder=folder, duration=2, bitrate=320, last_modification=0, ) self.trackid = track.id self.formats = ["mp3", "flac", "ogg", "m4a"] for i in range(len(self.formats)): track_embeded_art = Track( title="[silence]", number=1, disc=1, artist=artist, album=album, path=os.path.abspath( "tests/assets/formats/silence.{}".format( self.formats[i])), root_folder=folder, folder=folder, duration=2, bitrate=320, last_modification=0, ) self.formats[i] = track_embeded_art.id
def test_get_album(self): self._make_request('getAlbum', error = 10) self._make_request('getAlbum', { 'id': 'nastynasty' }, error = 0) self._make_request('getAlbum', { 'id': str(uuid.uuid4()) }, error = 70) with db_session: a = Album.select().first() rv, child = self._make_request('getAlbum', { 'id': str(a.id) }, tag = 'album') self.assertEqual(child.get('id'), str(a.id)) self.assertEqual(child.get('songCount'), str(len(child))) self.assertEqual(len(child), a.tracks.count()) for dal, xal in zip(sorted(a.tracks, key = lambda t: t.title), sorted(child, key = lambda c: c.get('title'))): self.assertEqual(dal.title, xal.get('title')) self.assertEqual(xal.get('album'), a.name) self.assertEqual(xal.get('albumId'), str(a.id))
def test_get_album(self): self._make_request('getAlbum', error = 10) self._make_request('getAlbum', { 'id': 'nastynasty' }, error = 0) self._make_request('getAlbum', { 'id': str(uuid.uuid4()) }, error = 70) with db_session: a = Album.select().first() rv, child = self._make_request('getAlbum', { 'id': str(a.id) }, tag = 'album') self.assertEqual(child.get('id'), str(a.id)) self.assertEqual(child.get('songCount'), str(len(child))) self.assertEqual(len(child), a.tracks.count()) for dal, xal in zip(sorted(a.tracks, key = lambda t: t.title), sorted(child, key = lambda c: c.get('title'))): self.assertEqual(dal.title, xal.get('title')) self.assertEqual(xal.get('album'), a.name) self.assertEqual(xal.get('albumId'), str(a.id))
def setUp(self): super(BrowseTestCase, self).setUp() with db_session: Folder(root = True, name = 'Empty root', path = '/tmp') root = Folder(root = True, name = 'Root folder', path = 'tests/assets') for letter in 'ABC': folder = Folder( name = letter + 'rtist', path = 'tests/assets/{}rtist'.format(letter), parent = root ) artist = Artist(name = letter + 'rtist') for lether in 'AB': afolder = Folder( name = letter + lether + 'lbum', path = 'tests/assets/{0}rtist/{0}{1}lbum'.format(letter, lether), parent = folder ) album = Album(name = letter + lether + 'lbum', artist = artist) for num, song in enumerate([ 'One', 'Two', 'Three' ]): track = Track( disc = 1, number = num, title = song, duration = 2, album = album, artist = artist, bitrate = 320, path = 'tests/assets/{0}rtist/{0}{1}lbum/{2}'.format(letter, lether, song), content_type = 'audio/mpeg', last_modification = 0, root_folder = root, folder = afolder ) self.assertEqual(Folder.select().count(), 11) self.assertEqual(Folder.select(lambda f: f.root).count(), 2) self.assertEqual(Artist.select().count(), 3) self.assertEqual(Album.select().count(), 6) self.assertEqual(Track.select().count(), 18)
def setUp(self): super(MediaTestCase, self).setUp() with db_session: folder = Folder(name='Root', path=os.path.abspath('tests/assets'), root=True, cover_art='cover.jpg') self.folderid = folder.id artist = Artist(name='Artist') album = Album(artist=artist, name='Album') track = Track(title='23bytes', number=1, disc=1, artist=artist, album=album, path=os.path.abspath('tests/assets/23bytes'), root_folder=folder, folder=folder, duration=2, bitrate=320, content_type='audio/mpeg', last_modification=0) self.trackid = track.id self.formats = [('mp3', 'mpeg'), ('flac', 'flac'), ('ogg', 'ogg')] for i in range(len(self.formats)): track_embeded_art = Track( title='[silence]', number=1, disc=1, artist=artist, album=album, path=os.path.abspath( 'tests/assets/formats/silence.{0}'.format( self.formats[i][0])), root_folder=folder, folder=folder, duration=2, bitrate=320, content_type='audio/{0}'.format(self.formats[i][1]), last_modification=0) self.formats[i] = track_embeded_art.id
def setUp(self): super(AlbumSongsTestCase, self).setUp() with db_session: folder = Folder(name='Root', root=True, path='tests/assets') artist = Artist(name='Artist') album = Album(name='Album', artist=artist) track = Track(title='Track', album=album, artist=artist, disc=1, number=1, path='tests/assets/empty', folder=folder, root_folder=folder, duration=2, bitrate=320, last_modification=0)
def test_get_album(self): self._make_request("getAlbum", error=10) self._make_request("getAlbum", {"id": "nastynasty"}, error=0) self._make_request("getAlbum", {"id": str(uuid.uuid4())}, error=70) with db_session: a = Album.select().first() rv, child = self._make_request("getAlbum", {"id": str(a.id)}, tag="album") self.assertEqual(child.get("id"), str(a.id)) self.assertEqual(child.get("songCount"), str(len(child))) self.assertEqual(len(child), a.tracks.count()) for dal, xal in zip( sorted(a.tracks, key=lambda t: t.title), sorted(child, key=lambda c: c.get("title")), ): self.assertEqual(dal.title, xal.get("title")) self.assertEqual(xal.get("album"), a.name) self.assertEqual(xal.get("albumId"), str(a.id))
def setUp(self): super(AlbumSongsTestCase, self).setUp() with db_session: folder = Folder(name="Root", root=True, path="tests/assets") artist = Artist(name="Artist") album = Album(name="Album", artist=artist) track = Track( title="Track", album=album, artist=artist, disc=1, number=1, path="tests/assets/empty", folder=folder, root_folder=folder, duration=2, bitrate=320, last_modification=0, )
def setUp(self): super(PlaylistTestCase, self).setUp() with db_session: root = Folder(root=True, name="Root folder", path="tests/assets") artist = Artist(name="Artist") album = Album(name="Album", artist=artist) songs = {} for num, song in enumerate(["One", "Two", "Three", "Four"]): track = Track( disc=1, number=num, title=song, duration=2, album=album, artist=artist, bitrate=320, path="tests/assets/" + song, last_modification=0, root_folder=root, folder=root, ) songs[song] = track users = {u.name: u for u in User.select()} playlist = Playlist(user=users["alice"], name="Alice's") playlist.add(songs["One"]) playlist.add(songs["Three"]) playlist = Playlist(user=users["alice"], public=True, name="Alice's public") playlist.add(songs["One"]) playlist.add(songs["Two"]) playlist = Playlist(user=users["bob"], name="Bob's") playlist.add(songs["Two"]) playlist.add(songs["Four"])
def setUp(self): super(PlaylistTestCase, self).setUp() with db_session: root = Folder(root = True, name = 'Root folder', path = 'tests/assets') artist = Artist(name = 'Artist') album = Album(name = 'Album', artist = artist) songs = {} for num, song in enumerate([ 'One', 'Two', 'Three', 'Four' ]): track = Track( disc = 1, number = num, title = song, duration = 2, album = album, artist = artist, bitrate = 320, path = 'tests/assets/' + song, content_type = 'audio/mpeg', last_modification = 0, root_folder = root, folder = root ) songs[song] = track users = { u.name: u for u in User.select() } playlist = Playlist(user = users['alice'], name = "Alice's") playlist.add(songs['One']) playlist.add(songs['Three']) playlist = Playlist(user = users['alice'], public = True, name = "Alice's public") playlist.add(songs['One']) playlist.add(songs['Two']) playlist = Playlist(user = users['bob'], name = "Bob's") playlist.add(songs['Two']) playlist.add(songs['Four'])
def setUp(self): super().setUp() with db_session: folder = Folder( name="Root", path=os.path.abspath("tests/assets/lyrics"), root=True, ) artist = Artist(name="Artist") album = Album(artist=artist, name="Album") Track( title="Nope", number=1, disc=1, artist=artist, album=album, path=os.path.abspath("tests/assets/lyrics/empty.mp3"), root_folder=folder, folder=folder, duration=2, bitrate=320, last_modification=0, ) Track( title="Yay", number=1, disc=1, artist=artist, album=album, path=os.path.abspath("tests/assets/lyrics/withlyrics.mp3"), root_folder=folder, folder=folder, duration=2, bitrate=320, last_modification=0, )
def setUp(self): super().setUp() with db_session: folder = Folder(name="Root", root=True, path="tests/assets") artist = Artist(name="Artist") album = Album(name="Album", artist=artist) Track( title="Track 1", album=album, artist=artist, disc=1, number=1, year=123, path="tests/assets/folder/1", folder=folder, root_folder=folder, duration=2, bitrate=320, last_modification=0, ) Track( title="Track 2", album=album, artist=artist, disc=1, number=1, year=124, genre="Lampshade", path="tests/assets/folder/2", folder=folder, root_folder=folder, duration=2, bitrate=320, last_modification=0, )
def test_get_album_list2(self): self._make_request("getAlbumList2", error=10) self._make_request("getAlbumList2", {"type": "void"}, error=0) self._make_request("getAlbumList2", { "type": "random", "size": "size_t" }, error=0) self._make_request("getAlbumList2", { "type": "newest", "offset": "&v + 2" }, error=0) self._make_request("getAlbumList2", {"type": "byYear"}, error=10) self._make_request( "getAlbumList2", { "type": "byYear", "fromYear": "Epoch", "toYear": "EOL" }, error=0, ) self._make_request("getAlbumList2", {"type": "byGenre"}, error=10) types = [ "random", "newest", "frequent", "recent", "starred", "alphabeticalByName", "alphabeticalByArtist", ] for t in types: self._make_request("getAlbumList2", {"type": t}, tag="albumList2", skip_post=t == "random") self._make_request("getAlbumList2", {"type": "random"}, tag="albumList2", skip_post=True) rv, child = self._make_request( "getAlbumList2", { "type": "byYear", "fromYear": 100, "toYear": 200 }, tag="albumList2", ) self.assertEqual(len(child), 1) rv, child = self._make_request( "getAlbumList2", { "type": "byYear", "fromYear": 200, "toYear": 300 }, tag="albumList2", ) self.assertEqual(len(child), 0) # Need more data to properly test ordering rv, child = self._make_request( "getAlbumList2", { "type": "byYear", "fromYear": 200, "toYear": 100 }, tag="albumList2", ) self.assertEqual(len(child), 1) rv, child = self._make_request("getAlbumList2", { "type": "byGenre", "genre": "FARTS" }, tag="albumList2") self.assertEqual(len(child), 0) rv, child = self._make_request("getAlbumList2", { "type": "byGenre", "genre": "Lampshade" }, tag="albumList2") self.assertEqual(len(child), 1) with db_session: Track.select().delete() Album.get().delete() rv, child = self._make_request("getAlbumList2", {"type": "random"}, tag="albumList2") self.assertEqual(len(child), 0)