def test_browse_albums(self):
        def ref(album):
            return Ref.album(name=album.name, uri=album.uri)

        with self.connection as c:
            self.assertEqual(map(ref, self.albums), schema.browse(
                c, Ref.ALBUM
            ))
            self.assertEqual(map(ref, []), schema.browse(
                c, Ref.ALBUM, artist=self.artists[0].uri
            ))
            self.assertEqual(map(ref, self.albums[1:2]), schema.browse(
                c, Ref.ALBUM, albumartist=self.artists[0].uri
            ))
 def test_browse_albums(self):
     with self.connection as c:
         self.assertItemsEqual(
             map(lambda m: m.uri, self.albums),
             map(lambda m: m.uri, schema.browse(c, Ref.ALBUM))
         )
         self.assertItemsEqual(
             map(lambda m: m.uri, []),
             map(lambda m: m.uri, schema.browse(c, Ref.ALBUM, artist=self.artists[0].uri))
         )
         self.assertItemsEqual(
             map(lambda m: m.uri, [self.albums[1]]),
             map(lambda m: m.uri, schema.browse(c, Ref.ALBUM, albumartist=self.artists[0].uri))
         )
    def test_browse_tracks(self):
        def ref(track):
            return Ref.track(name=track.name, uri=track.uri)

        with self.connection as c:
            self.assertEqual(map(ref, self.tracks), schema.browse(
                c, Ref.TRACK
            ))
            self.assertEqual(map(ref, self.tracks[1:2]), schema.browse(
                c, Ref.TRACK, artist=self.artists[0].uri
            ))
            self.assertEqual(map(ref, self.tracks[2:3]), schema.browse(
                c, Ref.TRACK, album=self.albums[0].uri
            ))
            self.assertEqual(map(ref, self.tracks[3:4]), schema.browse(
                c, Ref.TRACK, albumartist=self.artists[0].uri
            ))
            self.assertEqual(map(ref, self.tracks[4:5]), schema.browse(
                c, Ref.TRACK, composer=self.artists[0].uri,
                performer=self.artists[0].uri
            ))
 def test_browse_artists(self):
     with self.connection as c:
         self.assertItemsEqual(
             map(lambda m: m.uri, self.artists),
             map(lambda m: m.uri, schema.browse(c, Ref.ARTIST))
         )
         self.assertItemsEqual(
             map(lambda m: m.uri, self.artists),
             map(lambda m: m.uri, schema.browse(c, Ref.ARTIST, role=['artist', 'albumartist']))
         )
         self.assertItemsEqual(
             map(lambda m: m.uri, [self.artists[0]]),
             map(lambda m: m.uri, schema.browse(c, Ref.ARTIST, role='artist'))
         )
         self.assertItemsEqual(
             map(lambda m: m.uri, [self.artists[0]]),
             map(lambda m: m.uri, schema.browse(c, Ref.ARTIST, role='composer'))
         )
         self.assertItemsEqual(
             map(lambda m: m.uri, [self.artists[0]]),
             map(lambda m: m.uri, schema.browse(c, Ref.ARTIST, role='performer'))
         )
         self.assertItemsEqual(
             map(lambda m: m.uri, self.artists),
             map(lambda m: m.uri, schema.browse(c, Ref.ARTIST, role='albumartist'))
         )
 def test_browse_tracks(self):
     with self.connection as c:
         self.assertItemsEqual(
             map(lambda m: m.uri, self.tracks),
             map(lambda m: m.uri, schema.browse(c, Ref.TRACK))
         )
         self.assertItemsEqual(
             map(lambda m: m.uri, [self.tracks[1]]),
             map(lambda m: m.uri, schema.browse(c, Ref.TRACK, artist=self.artists[0].uri))
         )
         self.assertItemsEqual(
             map(lambda m: m.uri, [self.tracks[2]]),
             map(lambda m: m.uri, schema.browse(c, Ref.TRACK, album=self.albums[0].uri))
         )
         self.assertItemsEqual(
             map(lambda m: m.uri, [self.tracks[3]]),
             map(lambda m: m.uri, schema.browse(c, Ref.TRACK, albumartist=self.artists[0].uri))
         )
         self.assertItemsEqual(
             map(lambda m: m.uri, [self.tracks[4]]),
             map(lambda m: m.uri, schema.browse(
                 c, Ref.TRACK, composer=self.artists[0].uri, performer=self.artists[0].uri
             ))
         )
    def test_browse_artists(self):
        def ref(artist):
            return Ref.artist(name=artist.name, uri=artist.uri)

        with self.connection as c:
            self.assertEqual(map(ref, self.artists), schema.browse(
                c, Ref.ARTIST
            ))
            self.assertEqual(map(ref, self.artists), schema.browse(
                c, Ref.ARTIST, role=['artist', 'albumartist']
            ))
            self.assertEqual(map(ref, self.artists[0:1]), schema.browse(
                c, Ref.ARTIST, role='artist'
            ))
            self.assertEqual(map(ref, self.artists[0:1]), schema.browse(
                c, Ref.ARTIST, role='composer'
            ))
            self.assertEqual(map(ref, self.artists[0:1]), schema.browse(
                c, Ref.ARTIST, role='performer'
            ))
            self.assertEqual(map(ref, self.artists), schema.browse(
                c, Ref.ARTIST, role='albumartist'
            ))