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 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(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 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))