Hashable artist and album, for #82
This commit is contained in:
parent
1b5a09b404
commit
3fe197bbcc
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -27,6 +27,7 @@ pip-log.txt
|
||||||
pip-delete-this-directory.txt
|
pip-delete-this-directory.txt
|
||||||
|
|
||||||
# Unit test / coverage reports
|
# Unit test / coverage reports
|
||||||
|
htmlcov/
|
||||||
.tox/
|
.tox/
|
||||||
.coverage
|
.coverage
|
||||||
.cache
|
.cache
|
||||||
|
|
|
@ -1189,6 +1189,7 @@ class Album(_BaseObject, _Taggable):
|
||||||
title = None
|
title = None
|
||||||
artist = None
|
artist = None
|
||||||
username = None
|
username = None
|
||||||
|
__hash__ = _BaseObject.__hash__
|
||||||
|
|
||||||
def __init__(self, artist, title, network, username=None):
|
def __init__(self, artist, title, network, username=None):
|
||||||
"""
|
"""
|
||||||
|
@ -1358,6 +1359,7 @@ class Artist(_BaseObject, _Taggable):
|
||||||
|
|
||||||
name = None
|
name = None
|
||||||
username = None
|
username = None
|
||||||
|
__hash__ = _BaseObject.__hash__
|
||||||
|
|
||||||
def __init__(self, name, network, username=None):
|
def __init__(self, name, network, username=None):
|
||||||
"""Create an artist object.
|
"""Create an artist object.
|
||||||
|
|
|
@ -361,6 +361,32 @@ class TestPyLast(unittest.TestCase):
|
||||||
self.assertTrue(type(tags[0]) == pylast.TopItem)
|
self.assertTrue(type(tags[0]) == pylast.TopItem)
|
||||||
|
|
||||||
|
|
||||||
|
def test_album_is_hashable(self):
|
||||||
|
# Arrange
|
||||||
|
album = self.network.get_album("Test Artist", "Test Album")
|
||||||
|
albums = set()
|
||||||
|
|
||||||
|
# Act
|
||||||
|
albums.add(album)
|
||||||
|
|
||||||
|
# Assert
|
||||||
|
self.assertIsNotNone(album)
|
||||||
|
self.assertEqual(len(albums), 1)
|
||||||
|
|
||||||
|
|
||||||
|
def test_artist_is_hashable(self):
|
||||||
|
# Arrange
|
||||||
|
artist = self.network.get_artist("Test Artist")
|
||||||
|
artists = set()
|
||||||
|
|
||||||
|
# Act
|
||||||
|
artists.add(artist)
|
||||||
|
|
||||||
|
# Assert
|
||||||
|
self.assertIsNotNone(artist)
|
||||||
|
self.assertEqual(len(artists), 1)
|
||||||
|
|
||||||
|
|
||||||
def test_track_is_hashable(self):
|
def test_track_is_hashable(self):
|
||||||
# Arrange
|
# Arrange
|
||||||
lastfm_user = self.network.get_user(self.username)
|
lastfm_user = self.network.get_user(self.username)
|
||||||
|
@ -376,10 +402,6 @@ class TestPyLast(unittest.TestCase):
|
||||||
|
|
||||||
|
|
||||||
def test_user_is_hashable(self):
|
def test_user_is_hashable(self):
|
||||||
# TODO same for some other types
|
|
||||||
# https://github.com/hugovk/pylast/issues/82
|
|
||||||
# (passes in Python 2.7 but how about 3?)
|
|
||||||
|
|
||||||
# Arrange
|
# Arrange
|
||||||
lastfm_user = self.network.get_user(self.username)
|
lastfm_user = self.network.get_user(self.username)
|
||||||
users = set()
|
users = set()
|
||||||
|
|
Loading…
Reference in a new issue