def lastfm_recent_scrobbles_card(limit=10): """ Displays the most recent Scrobbles for all accounts. """ more = {'text': 'More at Last.fm', 'url': 'https://www.last.fm/user/gyford',} return { 'card_title': 'Recently played', 'scrobble_list': recent_scrobbles(limit=limit), 'more': more, }
def test_account_error(self): "Should raise TypeError if invalid Account is supplied." with self.assertRaises(TypeError): ditto_lastfm.recent_scrobbles(account='bob', limit=3)
def test_limit_error(self): "It throws an error if limit isn't an integer" with self.assertRaises(ValueError): ditto_lastfm.recent_scrobbles(limit='bob')
def test_limit(self): "It returns `limit` scrobbles" scrobbles = ditto_lastfm.recent_scrobbles(limit=3) self.assertEqual(len(scrobbles), 3)
def test_default_limit(self): "It returns 10 by default" scrobbles = ditto_lastfm.recent_scrobbles() self.assertEqual(len(scrobbles), 10)
def test_for_account(self): "With an Account, it gets its recent scrobbles" scrobbles = ditto_lastfm.recent_scrobbles( account=self.account1, limit=12) self.assertEqual(len(scrobbles), 11) self.assertNotIn(self.scrobble2, scrobbles)