def testDownloadImage(self): self._mockLastFMRequest() lastFM = LastFM() album_info = lastFM.getAlbumInfo(artist = 'Antonio Vivaldi', album = 'The four seasons') self._mockLastFMRequest('fixtures/last_fm/base_cover_image.jpg', 'rb') image_destionation_path = os.path.join(os.path.dirname(__file__), 'fixtures/test_downloaded_image.jpg') self.assertFalse(os.path.exists(image_destionation_path)) lastFM.downloadImage(album_info, 'mega', image_destionation_path) self.assertTrue(os.path.exists(image_destionation_path)) os.remove(image_destionation_path)
def testGetAllAlbumInfoGivenTheArtistAndAlbum(self): self._mockLastFMRequest() lastFM = LastFM() album_info = lastFM.getAlbumInfo(artist = 'Antonio Vivaldi', album = 'The four seasons') self.assertEquals('Antonio Vivaldi', album_info['artist']) self.assertEquals('The Four Seasons', album_info['album']) self.assertEquals(14, len(album_info['tracks'])) self.assertEquals(5, len(album_info['images'])) self.assertEquals(5, len(album_info['tags'])) self.assertEquals('http://userserve-ak.last.fm/serve/_/44462085/The+Four+Seasons.jpg', album_info['images']['mega'])