2008-09-16 21:08:01 +05:30
|
|
|
import unittest
|
|
|
|
import datetime
|
2008-09-16 21:19:30 +05:30
|
|
|
import sys
|
|
|
|
|
2008-09-17 01:16:48 +05:30
|
|
|
from wsgi_intercept.urllib2_intercept import install_opener
|
|
|
|
import wsgi_intercept
|
|
|
|
from wsgi_test_app import create_wsgi_app
|
2008-09-16 21:08:01 +05:30
|
|
|
|
2008-09-17 01:16:48 +05:30
|
|
|
install_opener()
|
|
|
|
wsgi_intercept.add_wsgi_intercept('ws.audioscrobbler.com', 80, create_wsgi_app)
|
|
|
|
|
|
|
|
sys.path.append("..")
|
|
|
|
from src import Api
|
2008-09-16 21:08:01 +05:30
|
|
|
|
2008-09-16 21:19:30 +05:30
|
|
|
class TestAlbum(unittest.TestCase):
|
2008-09-16 21:08:01 +05:30
|
|
|
""" A test class for the Album module. """
|
|
|
|
|
|
|
|
def setUp(self):
|
2008-09-17 01:16:48 +05:30
|
|
|
apikey = "152a230561e72192b8b0f3e42362c6ff"
|
|
|
|
self.api = Api(apikey, no_cache = True)
|
|
|
|
self.album = self.api.getAlbum("Oasis", "Supersonic")
|
|
|
|
|
|
|
|
def tearDown(self):
|
|
|
|
pass
|
|
|
|
|
2008-09-16 21:08:01 +05:30
|
|
|
def testAlbumName(self):
|
2008-09-17 01:16:48 +05:30
|
|
|
self.assertEqual(self.album.name, "Supersonic")
|
2008-09-16 21:08:01 +05:30
|
|
|
|
|
|
|
def testAlbumArtist(self):
|
2008-09-17 01:16:48 +05:30
|
|
|
self.assertEqual(self.album.artist.name, "Oasis")
|
|
|
|
|
|
|
|
def testAlbumId(self):
|
|
|
|
self.assertEqual(self.album.id, 2038492)
|
|
|
|
|
|
|
|
def testAlbumMbid(self):
|
|
|
|
mbid = '2c2a24de-67b6-483b-b597-9c6b7891ba90'
|
|
|
|
self.assertEqual(self.album.mbid, mbid)
|
2008-09-16 21:08:01 +05:30
|
|
|
|
|
|
|
def testAlbumUrl(self):
|
|
|
|
url = 'http://www.last.fm/music/Oasis/Supersonic'
|
2008-09-17 01:16:48 +05:30
|
|
|
self.assertEqual(self.album.url, url)
|
2008-09-16 21:08:01 +05:30
|
|
|
|
|
|
|
def testAlbumReleaseDate(self):
|
|
|
|
date = datetime.datetime(1994, 7, 28, 0, 0)
|
2008-09-17 01:16:48 +05:30
|
|
|
self.assertEqual(self.album.releaseDate, date)
|
2008-09-16 21:08:01 +05:30
|
|
|
|
2008-09-17 01:16:48 +05:30
|
|
|
def testAlbumImage(self):
|
|
|
|
self.assertEqual(self.album.image['small'], "http://userserve-ak.last.fm/serve/34/11846565.jpg")
|
|
|
|
self.assertEqual(self.album.image['medium'], "http://userserve-ak.last.fm/serve/64/11846565.jpg")
|
|
|
|
self.assertEqual(self.album.image['large'], "http://userserve-ak.last.fm/serve/174s/11846565.jpg")
|
|
|
|
self.assertEqual(self.album.image['extralarge'], "http://userserve-ak.last.fm/serve/300x300/11846565.jpg")
|
|
|
|
|
|
|
|
def testAlbumStats(self):
|
|
|
|
self.assertEqual(self.album.stats.listeners, 14286)
|
|
|
|
self.assertEqual(self.album.stats.playcount, 39594)
|
|
|
|
|
|
|
|
def testAlbumTopTags(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def testAlbumTopTag(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def testAlbumPlaylist(self):
|
|
|
|
self.assertEqual(self.album.playlist.url, "lastfm://playlist/album/2038492")
|
2008-09-16 21:08:01 +05:30
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|