When getting last scrobbled track, need to get at least two recent tracks because the last may be a now-playing and thus ignored.

This commit is contained in:
hugovk 2014-03-02 12:28:14 +02:00
parent b83113bda5
commit d125afd45f

View file

@ -55,7 +55,7 @@ class TestPyLast(unittest.TestCase):
self.network.scrobble(artist = artist, title = title, timestamp = timestamp) self.network.scrobble(artist = artist, title = title, timestamp = timestamp)
# Assert # Assert
last_scrobble = lastfm_user.get_recent_tracks(limit = 1)[0] last_scrobble = lastfm_user.get_recent_tracks(limit = 2)[0] # 2 to ignore now-playing
self.assertEqual(str(last_scrobble.track.artist), str(artist)) self.assertEqual(str(last_scrobble.track.artist), str(artist))
self.assertEqual(str(last_scrobble.track.title), str(title)) self.assertEqual(str(last_scrobble.track.title), str(title))
self.assertEqual(str(last_scrobble.timestamp), str(timestamp)) self.assertEqual(str(last_scrobble.timestamp), str(timestamp))
@ -74,7 +74,7 @@ class TestPyLast(unittest.TestCase):
library.remove_scrobble(artist = artist, title = title, timestamp = timestamp) library.remove_scrobble(artist = artist, title = title, timestamp = timestamp)
# Assert # Assert
last_scrobble = lastfm_user.get_recent_tracks(limit = 1)[0] last_scrobble = lastfm_user.get_recent_tracks(limit = 2)[0] # 2 to ignore now-playing
self.assertNotEqual(str(last_scrobble.timestamp), str(timestamp)) self.assertNotEqual(str(last_scrobble.timestamp), str(timestamp))
@ -184,7 +184,7 @@ class TestPyLast(unittest.TestCase):
# Assert # Assert
# Just check date because of timezones # Just check date because of timezones
self.assertEquals(unixtime_registered, u"1037793040") self.assertEqual(unixtime_registered, u"1037793040")
def test_get_genderless_user(self): def test_get_genderless_user(self):
@ -360,7 +360,7 @@ class TestPyLast(unittest.TestCase):
# Arrange # Arrange
lastfm_user = self.network.get_user(self.username) lastfm_user = self.network.get_user(self.username)
track = lastfm_user.get_recent_tracks(limit = 1)[0] track = lastfm_user.get_recent_tracks(limit = 2)[0] # 2 to ignore now-playing
tracks = set() tracks = set()
# Act # Act