Add artist.get_band_members() with tests
This commit is contained in:
parent
ff69189a6d
commit
e117a2b57c
15
pylast.py
15
pylast.py
|
@ -1023,7 +1023,7 @@ class _Request(object):
|
|||
def sign_it(self):
|
||||
"""Sign this request."""
|
||||
|
||||
if not "api_sig" in self.params.keys():
|
||||
if "api_sig" not in self.params.keys():
|
||||
self.params['api_sig'] = self._get_signature()
|
||||
|
||||
def _get_signature(self):
|
||||
|
@ -2093,6 +2093,17 @@ class Artist(_BaseObject, _Taggable):
|
|||
|
||||
self._request("artist.Shout", False, params)
|
||||
|
||||
def get_band_members(self):
|
||||
"""Returns a list of band members or None if unknown."""
|
||||
|
||||
names = None
|
||||
doc = self._request(self.ws_prefix + ".getInfo", True)
|
||||
|
||||
for node in doc.getElementsByTagName("bandmembers"):
|
||||
names = _extract_all(node, "name")
|
||||
|
||||
return names
|
||||
|
||||
|
||||
class Event(_BaseObject):
|
||||
"""An event."""
|
||||
|
@ -4115,7 +4126,7 @@ def _number(string):
|
|||
|
||||
def _unescape_htmlentity(string):
|
||||
|
||||
#string = _unicode(string)
|
||||
# string = _unicode(string)
|
||||
|
||||
mapping = htmlentitydefs.name2codepoint
|
||||
for key in mapping:
|
||||
|
|
|
@ -1251,7 +1251,7 @@ class TestPyLast(unittest.TestCase):
|
|||
# Assert
|
||||
# Check inbox for spam!
|
||||
|
||||
#album/artist/event/track/user
|
||||
# album/artist/event/track/user
|
||||
|
||||
def test_album_shouts(self):
|
||||
# Arrange
|
||||
|
@ -1750,7 +1750,6 @@ class TestPyLast(unittest.TestCase):
|
|||
self.assertEqual(mbid, "a74b1b7f-71a5-4011-9441-d0b5e4122711")
|
||||
self.assertIsInstance(streamable, bool)
|
||||
|
||||
|
||||
def test_events(self):
|
||||
# Arrange
|
||||
event_id_1 = 3162700 # Glasto 2013
|
||||
|
@ -1803,7 +1802,6 @@ class TestPyLast(unittest.TestCase):
|
|||
self.assertTrue(country1 != country2)
|
||||
self.assertEqual(url, "http://www.last.fm/place/italy")
|
||||
|
||||
|
||||
def test_track_eq_none_is_false(self):
|
||||
# Arrange
|
||||
track1 = None
|
||||
|
@ -1820,6 +1818,26 @@ class TestPyLast(unittest.TestCase):
|
|||
# Act / Assert
|
||||
self.assertTrue(track1 != track2)
|
||||
|
||||
def test_band_members(self):
|
||||
# Arrange
|
||||
artist = pylast.Artist("The Beatles", self.network)
|
||||
|
||||
# Act
|
||||
band_members = artist.get_band_members()
|
||||
|
||||
# Assert
|
||||
self.assertGreaterEqual(len(band_members), 4)
|
||||
|
||||
def test_no_band_members(self):
|
||||
# Arrange
|
||||
artist = pylast.Artist("John Lennon", self.network)
|
||||
|
||||
# Act
|
||||
band_members = artist.get_band_members()
|
||||
|
||||
# Assert
|
||||
self.assertIsNone(band_members)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(
|
||||
|
|
Loading…
Reference in a new issue