Skip to content

Commit

Permalink
Merge pull request #134 from egh/parse-artist-role
Browse files Browse the repository at this point in the history
Parse artist role field
  • Loading branch information
AnssiAhola authored Jul 18, 2023
2 parents 6292146 + ba4152f commit 7d53b36
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion discogs_client/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,10 @@ class Artist(PrimaryAPIObject):
#: single string, for example: "DJ ABC Feat MC Z". Also check out the
#: ``artists_sort`` attribute of a ``Release`` object.
join = SimpleField()

#: This attribute is only present when an ``Artist`` object is part of a
#: ``credits`` list of a ``Release`` object.
role = SimpleField()

def __init__(self, client, dict_):
super(Artist, self).__init__(client, dict_)
self.data['resource_url'] = '{0}/artists/{1}'.format(client._base_url, dict_['id'])
Expand Down
3 changes: 3 additions & 0 deletions discogs_client/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ def test_artist(self):
"""Artists can be fetched and parsed"""
a = self.d.artist(1)
self.assertEqual(a.name, 'Persuader, The')
a2 = self.d.release(1).credits[0]
self.assertEqual(a2.name, 'Jesper Dahlbäck')
self.assertEqual(a2.role, 'Music By [All Tracks By]')

def test_same_artist(self):
"""Artists can be fetched and parsed multiple times"""
Expand Down

0 comments on commit 7d53b36

Please sign in to comment.