def test_offsite_url_property(self): band_id = 3463798201 api = bandcamp.TestApi('test_single_band') band = bandcamp.band.info(api=api, band_id=band_id) self.assertEqual('http://www.amandapalmer.net', band.offsite_url)
def test_artist_property(self): album_id = 927252583 api = bandcamp.TestApi('test_album_tpwg') album = bandcamp.album.info(api=api, album_id=album_id) self.assertEqual('Renard', album.artist)
def test_band_id_property(self): track_id = 2846277250 api = bandcamp.TestApi('test_unicode_track') track = bandcamp.track.info(api=api, track_id=track_id) self.assertEqual(4180852708, track.band_id)
def test_band_id_property(self): album_id = 2587417518 api = bandcamp.TestApi('test_album') album = bandcamp.album.info(api=api, album_id=album_id) self.assertEqual(3463798201, album.band_id)
def test_subdomain_property(self): band_id = 3463798201 api = bandcamp.TestApi('test_single_band') band = bandcamp.band.info(api=api, band_id=band_id) self.assertEqual('amandapalmer', band.subdomain)
def test_album_url(self): url = 'lapfoxtrax.com/album/--2' api = bandcamp.TestApi('test_album_url') response = bandcamp.url.info(api=api, url=url) self.assertEqual(4180852708, response.band_id) self.assertEqual(1163674320, response.album_id)
def test_url_property(self): track_id = 2846277250 api = bandcamp.TestApi('test_unicode_track') track = bandcamp.track.info(api=api, track_id=track_id) self.assertEqual('/track/--2', track.url)
def test_search_more_than_twelve(self): """Verify that we raise an error when you try to search for more than 12 names""" name = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13'] api = bandcamp.TestApi('test_search_thirteen') with self.assertRaises(ValueError): bandcamp.band.search(api=api, name=name)
def test_title_property(self): album_id = 2587417518 api = bandcamp.TestApi('test_album') album = bandcamp.album.info(api=api, album_id=album_id) self.assertEqual('Who Killed Amanda Palmer', album.title)
def test_url_property(self): band_id = 3463798201 api = bandcamp.TestApi('test_single_band') band = bandcamp.band.info(api=api, band_id=band_id) self.assertEqual('http://amandapalmer.bandcamp.com', band.url)
def test_search_twelve(self): """Verify that we can search for 12 names""" name = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12'] api = bandcamp.TestApi('test_search_twelve') bands = bandcamp.band.search(api=api, name=name) self.assertEqual(96, len(bands))
def test_search_multiple(self): """Verify that we can search for multiple names""" name = ['lapfox', 'aviators'] api = bandcamp.TestApi('test_search_multiple') bands = bandcamp.band.search(api=api, name=name) self.assertEqual(8, len(bands))
def test_search_with_no_results(self): """Verify that we can handle a search that returns no results""" name = 'unittest' api = bandcamp.TestApi('test_search_unittest') bands = bandcamp.band.search(api=api, name=name) self.assertEqual({}, bands)
def test_large_art_url_property(self): album_id = 2587417518 api = bandcamp.TestApi('test_album') album = bandcamp.album.info(api=api, album_id=album_id) self.assertEqual('http://f0.bcbits.com/img/a1968148812_2.jpg', album.large_art_url)
def test_unicode(self): """Verify that we can handle a unicode title""" track_id = 2846277250 api = bandcamp.TestApi('test_unicode_track') track = bandcamp.track.info(api=api, track_id=track_id) self.assertEqual('\u266b \u2160\uff0f \u2764\u2764\u2764', track.title)
def test_unknown_property_is_none(self): """Verify that a property that was not in the response is None""" track_id = 1269403107 api = bandcamp.TestApi('test_single_track') track = bandcamp.track.info(api=api, track_id=track_id) self.assertIsNone(track.large_art_url)
def test_large_art_url_property(self): band_id = 203035041 api = bandcamp.TestApi('test_single_discography') discography = bandcamp.band.discography(api=api, band_id=band_id) album = discography.albums[4246425639] self.assertEqual('http://f0.bcbits.com/img/a0897080833_2.jpg', album.large_art_url)
def test_downloadable_property(self): """Verify that the downloadable property returns a enum member""" track_id = 1269403107 api = bandcamp.TestApi('test_single_track') track = bandcamp.track.info(api=api, track_id=track_id) self.assertEqual(bandcamp.track.DownloadableStates.PAID, track.downloadable)
def test_credits_property(self): album_id = 2587417518 api = bandcamp.TestApi('test_album') album = bandcamp.album.info(api=api, album_id=album_id) self.assertEqual( 'For a complete list of credits, please visit http://www.whokilledamandapalmer.com/credits.php', album.credits)
def test_about_property(self): album_id = 2587417518 api = bandcamp.TestApi('test_album') album = bandcamp.album.info(api=api, album_id=album_id) self.assertEqual( 'For additional information including a recording-diary by Amanda, exclusive videos, liner notes, lyrics, and much more, please visit http://www.whokilledamandapalmer.com', album.about)
def test_single_album(self): """Verify that a single album can be fetched""" album_id = 2587417518 api = bandcamp.TestApi('test_album') album = bandcamp.album.info(api=api, album_id=album_id) self.assertIsInstance(album, bandcamp.album.Album) self.assertEqual(album_id, album.album_id)
def test_url_property(self): album_id = 927252583 api = bandcamp.TestApi('test_album') album = bandcamp.album.info(api=api, album_id=album_id) self.assertEqual( 'http://amandapalmer.bandcamp.com/album/who-killed-amanda-palmer?pk=564', album.url)
def test_band_track_url(self): url = 'http://music.sufjan.com/track/enchanting-ghost' api = bandcamp.TestApi('test_band_track_url') response = bandcamp.url.info(api=api, url=url) self.assertEqual(203035041, response.band_id) self.assertEqual(2323108455, response.track_id) self.assertIsNone(response.album_id)
def test_search_with_one_result(self): """Verify that we can handle a search that returns a single band""" name = 'Mumble' api = bandcamp.TestApi('test_search_mumble') band = bandcamp.band.search(api=api, name=name) self.assertIsInstance(band, bandcamp.band.Band) self.assertEqual(name, band.name)
def test_about_property(self): track_id = 1269403107 api = bandcamp.TestApi('test_single_track') track = bandcamp.track.info(api=api, track_id=track_id) self.assertEqual( 'Recorded live in Prague, Czech Republic at Palác Akropolis on May 5th, 2010', track.about)
def test_band_url(self): url = 'cults.bandcamp.com' api = bandcamp.TestApi('test_band_url') response = bandcamp.url.info(api=api, url=url) self.assertEqual(4214473200, response.band_id) self.assertIsNone(response.album_id) self.assertIsNone(response.track_id)
def test_single_track_int(self): """Verify that a single track can be fetched with its track id as a number""" track_id = 1269403107 api = bandcamp.TestApi('test_single_track') track = bandcamp.track.info(api=api, track_id=track_id) self.assertIsInstance(track, bandcamp.track.Track) self.assertEqual(track_id, track.track_id)
def test_release_date(self): """Verify that the release_date returns a time_struct""" album_id = 2587417518 # tpwg stands for "This Place Will Grow" which is the album title ;) api = bandcamp.TestApi('test_album_tpwg') album = bandcamp.album.info(api=api, album_id=album_id) self.assertIsInstance(album.release_date, time.struct_time)
def test_credits_property(self): band_id = 203035041 api = bandcamp.TestApi('test_single_discography') discography = bandcamp.band.discography(api=api, band_id=band_id) album = discography.albums[4246425639] self.assertFalse(hasattr(album, 'credits'))
def test_album_id_property(self): band_id = 203035041 api = bandcamp.TestApi('test_single_discography') discography = bandcamp.band.discography(api=api, band_id=band_id) album = discography.albums[4246425639] self.assertEqual(4246425639, album.album_id)