rockstar-custom 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. data/.travis.yml +6 -0
  2. data/Gemfile +11 -0
  3. data/Gemfile.lock +22 -0
  4. data/History.txt +6 -0
  5. data/MIT-LICENSE +19 -0
  6. data/Manifest +72 -0
  7. data/README.md +135 -0
  8. data/Rakefile +34 -0
  9. data/VERSION +1 -0
  10. data/examples/.gitignore +1 -0
  11. data/examples/album.rb +16 -0
  12. data/examples/artist.rb +23 -0
  13. data/examples/geo.rb +9 -0
  14. data/examples/lastfm.yml_example +3 -0
  15. data/examples/scrobble.rb +45 -0
  16. data/examples/tag.rb +20 -0
  17. data/examples/track.rb +14 -0
  18. data/examples/user.rb +18 -0
  19. data/lib/rockstar.rb +50 -0
  20. data/lib/rockstar/album.rb +109 -0
  21. data/lib/rockstar/artist.rb +182 -0
  22. data/lib/rockstar/auth.rb +21 -0
  23. data/lib/rockstar/base.rb +48 -0
  24. data/lib/rockstar/chart.rb +31 -0
  25. data/lib/rockstar/event.rb +73 -0
  26. data/lib/rockstar/geo.rb +22 -0
  27. data/lib/rockstar/metro.rb +26 -0
  28. data/lib/rockstar/playing.rb +50 -0
  29. data/lib/rockstar/rest.rb +66 -0
  30. data/lib/rockstar/scrobble.rb +68 -0
  31. data/lib/rockstar/session.rb +19 -0
  32. data/lib/rockstar/simpleauth.rb +62 -0
  33. data/lib/rockstar/tag.rb +100 -0
  34. data/lib/rockstar/tokenauth.rb +84 -0
  35. data/lib/rockstar/track.rb +260 -0
  36. data/lib/rockstar/user.rb +200 -0
  37. data/lib/rockstar/venue.rb +59 -0
  38. data/lib/rockstar/version.rb +3 -0
  39. data/rockstar.gemspec +174 -0
  40. data/test/fixtures/xml/album/getinfo_album_Radio_Retalation_artist_Thievery_Corporation.xml +21 -0
  41. data/test/fixtures/xml/album/getinfo_album_Some_Hearts_artist_Carrie_Underwood.xml +63 -0
  42. data/test/fixtures/xml/artist/getevents_artist_Metallica.xml +1064 -0
  43. data/test/fixtures/xml/artist/getimages_artist_Metallica_page_2.xml +1074 -0
  44. data/test/fixtures/xml/artist/getinfo_artist_Metallica.xml +115 -0
  45. data/test/fixtures/xml/artist/getsimilar_artist_Metallica.xml +1203 -0
  46. data/test/fixtures/xml/artist/gettopalbums_artist_Metallica.xml +704 -0
  47. data/test/fixtures/xml/artist/gettopfans_artist_Metallica.xml +504 -0
  48. data/test/fixtures/xml/artist/gettoptags_artist_Metallica.xml +403 -0
  49. data/test/fixtures/xml/artist/gettoptracks_artist_Metallica.xml +800 -0
  50. data/test/fixtures/xml/geo/getevents_location_london.xml +531 -0
  51. data/test/fixtures/xml/geo/getmetros_country_germany.xml +44 -0
  52. data/test/fixtures/xml/tag/gettopalbums_tag_rock.xml +654 -0
  53. data/test/fixtures/xml/tag/gettopartists_tag_rock.xml +504 -0
  54. data/test/fixtures/xml/tag/gettoptags.xml +1253 -0
  55. data/test/fixtures/xml/tag/gettoptracks_tag_rock.xml +704 -0
  56. data/test/fixtures/xml/track/getinfo_artist_Carrie_Underwood_track_Before_He_Cheats.xml +55 -0
  57. data/test/fixtures/xml/track/gettopfans_artist_Carrie_Underwood_track_Before_He_Cheats.xml +504 -0
  58. data/test/fixtures/xml/track/gettoptags_artist_Carrie_Underwood_track_Before_He_Cheats.xml +403 -0
  59. data/test/fixtures/xml/track/love_artist_Carrie_Underwood_sk_tag_track_Before_He_Cheats.xml +2 -0
  60. data/test/fixtures/xml/track/updatenowplaying_artist_Carrie_Underwood_sk_tag_track_Before_He_Cheats.xml +10 -0
  61. data/test/fixtures/xml/user/getevents_sk_token_user_bodot.xml +513 -0
  62. data/test/fixtures/xml/user/getfriends_user_jnunemaker.xml +173 -0
  63. data/test/fixtures/xml/user/getinfo_user_jnunemaker.xml +22 -0
  64. data/test/fixtures/xml/user/getinfo_user_oaknd1.xml +22 -0
  65. data/test/fixtures/xml/user/getinfo_user_wharle.xml +22 -0
  66. data/test/fixtures/xml/user/getlovedtracks_user_jnunemaker.xml +775 -0
  67. data/test/fixtures/xml/user/getneighbours_user_jnunemaker.xml +503 -0
  68. data/test/fixtures/xml/user/getrecenttracks_user_jnunemaker.xml +133 -0
  69. data/test/fixtures/xml/user/getrecommendedartists_sk_token_user_jnunemaker.xml +553 -0
  70. data/test/fixtures/xml/user/gettopalbums_user_jnunemaker.xml +704 -0
  71. data/test/fixtures/xml/user/gettopartists_period_overall_user_jnunemaker.xml +554 -0
  72. data/test/fixtures/xml/user/gettoptags_user_jnunemaker.xml +63 -0
  73. data/test/fixtures/xml/user/gettoptracks_user_jnunemaker.xml +750 -0
  74. data/test/fixtures/xml/user/getweeklyalbumchart_from_1138536002_to_1139140802_user_jnunemaker.xml +143 -0
  75. data/test/fixtures/xml/user/getweeklyalbumchart_from__to__user_jnunemaker.xml +31 -0
  76. data/test/fixtures/xml/user/getweeklyartistchart_from_1138536002_to_1139140802_user_jnunemaker.xml +201 -0
  77. data/test/fixtures/xml/user/getweeklyartistchart_from__to__user_jnunemaker.xml +21 -0
  78. data/test/fixtures/xml/user/getweeklychartlist_user_jnunemaker.xml +232 -0
  79. data/test/fixtures/xml/user/getweeklytrackchart_from_1138536002_to_1139140802_user_jnunemaker.xml +883 -0
  80. data/test/fixtures/xml/user/getweeklytrackchart_from__to__user_jnunemaker.xml +423 -0
  81. data/test/fixtures/xml/venue/getevents_venue_8807850.xml +280 -0
  82. data/test/fixtures/xml/venue/search_country__limit__page__venue_country_DE_venue_cotton.xml +72 -0
  83. data/test/mocks/rest.rb +67 -0
  84. data/test/test_helper.rb +18 -0
  85. data/test/unit/test_album.rb +76 -0
  86. data/test/unit/test_artist.rb +102 -0
  87. data/test/unit/test_chart.rb +35 -0
  88. data/test/unit/test_geo.rb +25 -0
  89. data/test/unit/test_playing.rb +53 -0
  90. data/test/unit/test_scrobble.rb +69 -0
  91. data/test/unit/test_simpleauth.rb +45 -0
  92. data/test/unit/test_tag.rb +57 -0
  93. data/test/unit/test_tokenauth.rb +45 -0
  94. data/test/unit/test_track.rb +82 -0
  95. data/test/unit/test_user.rb +299 -0
  96. data/test/unit/test_venue.rb +20 -0
  97. metadata +269 -0
@@ -0,0 +1,69 @@
1
+ require File.expand_path('../../test_helper.rb', __FILE__)
2
+
3
+ class TestScrobble < Test::Unit::TestCase
4
+
5
+ def setup
6
+ @session_id = '17E61E13454CDD8B68E8D7DEEEDF6170'
7
+ @submission_url = 'http://62.216.251.205:80/protocol_1.2'
8
+ @artist = 'Coldplay'
9
+ @name = 'Viva La Vida'
10
+
11
+ @scrobble = Rockstar::Scrobble.new(:session_id => @session_id, :submission_url => @submission_url,
12
+ :artist => @artist, :track => @name, :album => @name, :time => Time.new,
13
+ :length => 244, :track_number => 7)
14
+ end
15
+
16
+ test 'should require a session id' do
17
+ assert_raises(ArgumentError) { Rockstar::Scrobble.new(:submission_url => @submission_url,
18
+ :artist => @artist, :track => @name, :album => @name, :time => Time.new,
19
+ :length => 244, :track_number => 7) }
20
+ end
21
+
22
+ test 'should require a submission url' do
23
+ assert_raises(ArgumentError) { Rockstar::Scrobble.new(:session_id => @session_id,
24
+ :artist => @artist, :track => @name, :album => @name, :time => Time.new,
25
+ :length => 244, :track_number => 7) }
26
+ end
27
+
28
+ test 'should require an artist' do
29
+ assert_raises(ArgumentError) { Rockstar::Scrobble.new(:session_id => @session_id, :submission_url => @submission_url,
30
+ :track => @name, :album => @name, :time => Time.new,
31
+ :length => 244, :track_number => 7) }
32
+ end
33
+
34
+ test 'should require a track' do
35
+ assert_raises(ArgumentError) { Rockstar::Scrobble.new(:session_id => @session_id, :submission_url => @submission_url,
36
+ :artist => @artist, :album => @name, :time => Time.new,
37
+ :length => 244, :track_number => 7) }
38
+ end
39
+
40
+ test 'should require a Time object' do
41
+ assert_raises(ArgumentError) { Rockstar::Scrobble.new(:session_id => @session_id, :submission_url => @submission_url,
42
+ :artist => @artist, :track => @name, :album => @name, :time => 'chunky_bacon',
43
+ :length => 244, :track_number => 7) }
44
+ end
45
+
46
+ test 'should require a valid source' do
47
+ assert_raises(ArgumentError) { Rockstar::Scrobble.new(:session_id => @session_id, :submission_url => @submission_url,
48
+ :artist => @artist, :track => @name, :album => @name, :time => Time.new,
49
+ :length => 244, :track_number => 7, :source => 'Z') }
50
+ end
51
+
52
+ test 'should require a length if source is set to P' do
53
+ assert_raises(ArgumentError) { Rockstar::Scrobble.new(:session_id => @session_id, :submission_url => @submission_url,
54
+ :artist => @artist, :track => @name, :album => @name, :time => Time.new,
55
+ :track_number => 7, :source => 'P') }
56
+ end
57
+
58
+ test 'should require a length greater than 30 if source is set to P' do
59
+ assert_raises(ArgumentError) { Rockstar::Scrobble.new(:session_id => @session_id, :submission_url => @submission_url,
60
+ :artist => @artist, :track => @name, :album => @name, :time => Time.new,
61
+ :length => 29, :track_number => 7, :source => 'P') }
62
+ end
63
+
64
+ test 'should submit successfully' do
65
+ @scrobble.submit!
66
+ assert_equal('OK', @scrobble.status)
67
+ end
68
+
69
+ end
@@ -0,0 +1,45 @@
1
+ require File.expand_path('../../test_helper.rb', __FILE__)
2
+
3
+ class TestSimpleAuth < Test::Unit::TestCase
4
+
5
+ def setup
6
+ @auth = Rockstar::SimpleAuth.new(:user => 'chunky', :password => 'bacon')
7
+ end
8
+
9
+ test 'should require a user' do
10
+ assert_raises(ArgumentError) { Rockstar::SimpleAuth.new(:password => 'bacon') }
11
+ end
12
+
13
+ test 'should require a password' do
14
+ assert_raises(ArgumentError) { Rockstar::SimpleAuth.new(:user => 'chunky') }
15
+ end
16
+
17
+ test 'should have the right client id' do
18
+ assert_equal('rck', @auth.client_id)
19
+ end
20
+
21
+ test 'should have the right version' do
22
+ assert_equal(Rockstar::Version, @auth.client_ver)
23
+ end
24
+
25
+ test 'should handshake successfully' do
26
+ @auth.handshake!
27
+ assert_equal('OK', @auth.status)
28
+ end
29
+
30
+ test 'should get a session id' do
31
+ @auth.handshake!
32
+ assert_equal('17E61E13454CDD8B68E8D7DEEEDF6170', @auth.session_id)
33
+ end
34
+
35
+ test 'should get a now playing url' do
36
+ @auth.handshake!
37
+ assert_equal('http://62.216.251.203:80/nowplaying', @auth.now_playing_url)
38
+ end
39
+
40
+ test 'should get a submission url' do
41
+ @auth.handshake!
42
+ assert_equal('http://62.216.251.205:80/protocol_1.2', @auth.submission_url)
43
+ end
44
+
45
+ end
@@ -0,0 +1,57 @@
1
+ require File.expand_path('../../test_helper.rb', __FILE__)
2
+
3
+ class TestTag < Test::Unit::TestCase
4
+
5
+ def setup
6
+ @tag = Rockstar::Tag.new('rock')
7
+ end
8
+
9
+ test 'should be able to find the top tags for the entire system' do
10
+ assert_equal(250, Rockstar::Tag.top_tags.size)
11
+ assert_equal('rock', Rockstar::Tag.top_tags.first.name)
12
+ assert_equal('2920270', Rockstar::Tag.top_tags.first.count)
13
+ assert_equal('http://www.last.fm/tag/rock', Rockstar::Tag.top_tags.first.url)
14
+ end
15
+
16
+ test 'should require name' do
17
+ assert_raise(ArgumentError) { Rockstar::Tag.new('') }
18
+ end
19
+
20
+ test 'should have name' do
21
+ assert_equal('rock', @tag.name)
22
+ end
23
+
24
+ test 'should be able to find top artists for a tag' do
25
+ assert_equal(50, @tag.top_artists.size)
26
+ assert_equal('The Beatles', @tag.top_artists.first.name)
27
+ assert_equal('yes', @tag.top_artists.first.streamable)
28
+ assert_equal('b10bbbfc-cf9e-42e0-be17-e2c3e1d2600d', @tag.top_artists.first.mbid)
29
+ assert_equal('http://www.last.fm/music/The+Beatles', @tag.top_artists.first.url)
30
+ assert_equal('http://userserve-ak.last.fm/serve/34/4069917.jpg', @tag.top_artists.first.thumbnail)
31
+ assert_equal('http://userserve-ak.last.fm/serve/64/4069917.jpg', @tag.top_artists.first.image)
32
+ end
33
+
34
+ test 'should be able to find top albums for a tag' do
35
+ assert_equal(50, @tag.top_albums.size)
36
+ assert_equal('Stadium Arcadium', @tag.top_albums.first.name)
37
+ assert_equal('Red Hot Chili Peppers', @tag.top_albums.first.artist)
38
+ assert_equal('8bfac288-ccc5-448d-9573-c33ea2aa5c30', @tag.top_albums.first.artist_mbid)
39
+ assert_equal('http://www.last.fm/music/Red+Hot+Chili+Peppers/Stadium+Arcadium', @tag.top_albums.first.url)
40
+ assert_equal('http://userserve-ak.last.fm/serve/34s/8810061.jpg', @tag.top_albums.first.image(:small))
41
+ assert_equal('http://userserve-ak.last.fm/serve/64s/8810061.jpg', @tag.top_albums.first.image(:medium))
42
+ assert_equal('http://userserve-ak.last.fm/serve/126/8810061.jpg', @tag.top_albums.first.image(:large))
43
+ end
44
+
45
+ test 'should be able to find top tracks for a tag' do
46
+ assert_equal(50, @tag.top_tracks.size)
47
+ first = @tag.top_tracks.first
48
+ assert_equal('Californication', first.name)
49
+ assert_equal('yes', first.streamable)
50
+ assert_equal('Red Hot Chili Peppers', first.artist)
51
+ assert_equal('8bfac288-ccc5-448d-9573-c33ea2aa5c30', first.artist_mbid)
52
+ assert_equal('http://www.last.fm/music/Red+Hot+Chili+Peppers/_/Californication', first.url)
53
+ assert_equal('http://userserve-ak.last.fm/serve/34s/42739473.png', first.thumbnail)
54
+ assert_equal('http://userserve-ak.last.fm/serve/64s/42739473.png', first.image)
55
+ end
56
+
57
+ end
@@ -0,0 +1,45 @@
1
+ require File.expand_path('../../test_helper.rb', __FILE__)
2
+
3
+ class TestTokenAuth < Test::Unit::TestCase
4
+
5
+ def setup
6
+ Rockstar.lastfm = {"api_secret" => 'secret', "api_key" => 'api'}
7
+ @auth = Rockstar::TokenAuth.new(:username => 'chunky', :token => 'bacon')
8
+ end
9
+
10
+ test 'should require a user' do
11
+ assert_raises(ArgumentError) { Rockstar::SimpleAuth.new(:token => 'bacon') }
12
+ end
13
+
14
+ test 'should require a password' do
15
+ assert_raises(ArgumentError) { Rockstar::SimpleAuth.new(:user => 'chunky') }
16
+ end
17
+
18
+ test 'should have the right client id' do
19
+ assert_equal('rck', @auth.client_id)
20
+ end
21
+
22
+ test 'should have the right version' do
23
+ assert_equal(Rockstar::Version, @auth.client_ver)
24
+ end
25
+
26
+ test 'should handshake successfully' do
27
+ @auth.handshake!
28
+ assert_equal('OK', @auth.status)
29
+ end
30
+
31
+ test 'should get a session id' do
32
+ @auth.handshake!
33
+ assert_equal('17E61E13454CDD8B68E8D7DEEEDF6170', @auth.session_id)
34
+ end
35
+
36
+ test 'should get a now playing url' do
37
+ @auth.handshake!
38
+ assert_equal('http://62.216.251.203:80/nowplaying', @auth.now_playing_url)
39
+ end
40
+
41
+ test 'should get a submission url' do
42
+ @auth.handshake!
43
+ assert_equal('http://62.216.251.205:80/protocol_1.2', @auth.submission_url)
44
+ end
45
+ end
@@ -0,0 +1,82 @@
1
+ require File.expand_path('../../test_helper.rb', __FILE__)
2
+
3
+ class TestTrack < Test::Unit::TestCase
4
+
5
+ def setup
6
+ @track = Rockstar::Track.new('Carrie Underwood', 'Before He Cheats')
7
+ end
8
+
9
+ test 'should require the artist name' do
10
+ assert_raises(ArgumentError) { Rockstar::Track.new('', 'Before He Cheats') }
11
+ end
12
+
13
+ test 'should require the track name' do
14
+ assert_raises(ArgumentError) { Rockstar::Track.new('Carrie Underwood', '') }
15
+ end
16
+
17
+ test "should know the artist" do
18
+ assert_equal('Carrie Underwood', @track.artist)
19
+ end
20
+
21
+ test 'should know the name' do
22
+ assert_equal('Before He Cheats', @track.name)
23
+ end
24
+
25
+ test 'should be able to load track info' do
26
+ @track.load_info
27
+ assert_equal('http://www.last.fm/music/Carrie+Underwood/_/Before+He+Cheats', @track.url)
28
+ assert_equal('1040848', @track.playcount)
29
+ assert_match(/named the 2007 Single of the Year by the Country Music Association/, @track.summary)
30
+ end
31
+
32
+ test 'should be able to request detailed album info on initialize' do
33
+ track = Rockstar::Track.new('Carrie Underwood', 'Before He Cheats', :include_info => true)
34
+ assert_equal('Carrie Underwood', track.artist)
35
+ assert_equal('http://www.last.fm/music/Carrie+Underwood/_/Before+He+Cheats', track.url)
36
+ assert_equal('1040848', track.playcount)
37
+ assert_match(/named the 2007 Single of the Year by the Country Music Association/, track.summary)
38
+ end
39
+
40
+ test 'should have albums' do
41
+ assert_equal(1, @track.albums.size)
42
+ assert_equal('Some Hearts', @track.albums.first.name)
43
+ assert_equal('http://www.last.fm/music/Carrie+Underwood/Some+Hearts', @track.albums.first.url)
44
+ assert_equal('a33b9822-9f09-4e19-9d6e-e05af85c727b', @track.albums.first.mbid)
45
+ end
46
+
47
+ test 'should have fans' do
48
+ assert_equal(50, @track.fans.size)
49
+ assert_equal('chelseaf89', @track.fans.first.username)
50
+ assert_equal('http://www.last.fm/user/chelseaf89', @track.fans.first.url)
51
+ assert_equal('http://userserve-ak.last.fm/serve/34/41303325.jpg', @track.fans.first.avatar)
52
+ assert_equal('5000000', @track.fans.first.weight)
53
+ end
54
+
55
+ test 'should have top tags' do
56
+ assert_equal(100, @track.tags.size)
57
+ assert_equal('country', @track.tags.first.name)
58
+ assert_equal('100', @track.tags.first.count)
59
+ assert_equal('http://www.last.fm/tag/country', @track.tags.first.url)
60
+ end
61
+
62
+ test 'can love tracks' do
63
+ assert_equal('ok', @track.love("tag"))
64
+ end
65
+
66
+ test 'raise missing parameter error in scrobble' do
67
+ assert_raises(ArgumentError) { Rockstar::Track.scrobble() }
68
+ end
69
+
70
+ test 'can scrobble tracks' do
71
+ assert_equal('ok', @track.scrobble(Time.utc(2010,10,10,8,10), 'tag'))
72
+ end
73
+
74
+ test 'raise missing parameter error in update now playing' do
75
+ assert_raises(ArgumentError) { Rockstar::Track.updateNowPlaying() }
76
+ end
77
+
78
+ test 'can send current playing track' do
79
+ assert_equal('ok', @track.updateNowPlaying(Time.utc(2010,10,10,8,10), 'tag'))
80
+ end
81
+
82
+ end
@@ -0,0 +1,299 @@
1
+ # encoding: utf-8
2
+ require File.expand_path('../../test_helper.rb', __FILE__)
3
+
4
+ class TestUser < Test::Unit::TestCase
5
+
6
+ def setup
7
+ @user = Rockstar::User.new('jnunemaker')
8
+ end
9
+
10
+ test 'should be able to find one user' do
11
+ assert_equal(@user.username, Rockstar::User.find('jnunemaker').username)
12
+ end
13
+
14
+ test 'should be able to find multiple users' do
15
+ users = Rockstar::User.find('jnunemaker', 'oaknd1', 'wharle')
16
+ assert_equal(%w{jnunemaker oaknd1 wharle}, users.collect(&:username))
17
+ end
18
+
19
+ test 'should be able to find multiple users using an array' do
20
+ users = Rockstar::User.find(%w{jnunemaker oaknd1 wharle})
21
+ assert_equal(%w{jnunemaker oaknd1 wharle}, users.collect(&:username))
22
+ end
23
+
24
+ test 'should be able to load profile while finding' do
25
+ user = Rockstar::User.find('jnunemaker', :include_profile => true)
26
+ assert_equal(@user.username, user.username)
27
+ assert_equal('3017870', user.id)
28
+ end
29
+
30
+ test 'should be able to load profile while finding multiple users' do
31
+ users = Rockstar::User.find('jnunemaker', 'oaknd1', 'wharle', :include_profile => true)
32
+ assert_equal(3, users.size)
33
+ end
34
+
35
+ test 'should be able to include profile during initialization' do
36
+ user = Rockstar::User.new('jnunemaker', :include_profile => true)
37
+ assert_equal('3017870', user.id)
38
+ assert_equal('http://www.last.fm/user/jnunemaker', user.url)
39
+ assert_equal('John Nunemaker', user.realname)
40
+ assert_equal('2005-12-08 13:58', user.registered)
41
+ assert_equal('1134050307', user.registered_unixtime)
42
+ assert_equal('28', user.age)
43
+ assert_equal('m', user.gender)
44
+ assert_equal('US', user.country)
45
+ assert_equal('35853', user.playcount)
46
+ assert_equal('http://userserve-ak.last.fm/serve/34/4994806.jpg', user.avatar)
47
+ end
48
+
49
+ test 'should be able to load users profile' do
50
+ @user.load_profile
51
+ assert_equal('3017870', @user.id)
52
+ assert_equal('http://www.last.fm/user/jnunemaker', @user.url)
53
+ assert_equal('John Nunemaker', @user.realname)
54
+ assert_equal('2005-12-08 13:58', @user.registered)
55
+ assert_equal('1134050307', @user.registered_unixtime)
56
+ assert_equal('28', @user.age)
57
+ assert_equal('m', @user.gender)
58
+ assert_equal('US', @user.country)
59
+ assert_equal('35853', @user.playcount)
60
+ assert_equal('http://userserve-ak.last.fm/serve/34/4994806.jpg', @user.avatar)
61
+ end
62
+
63
+ test "should be able to get a user's top artists" do
64
+ assert_equal(50, @user.top_artists.size)
65
+ first = @user.top_artists.first
66
+ assert_equal('Taylor Swift', first.name)
67
+ assert_equal('20244d07-534f-4eff-b4d4-930878889970', first.mbid)
68
+ assert_equal('1392', first.playcount)
69
+ assert_equal('1', first.rank)
70
+ assert_equal('http://www.last.fm/music/Taylor+Swift', first.url)
71
+ assert_equal('http://userserve-ak.last.fm/serve/34/30883349.png', first.thumbnail)
72
+ assert_equal('http://userserve-ak.last.fm/serve/64/30883349.png', first.image)
73
+ end
74
+
75
+ test 'should be able to get top albums' do
76
+ assert_equal(50, @user.top_albums.size)
77
+ first = @user.top_albums.first
78
+ assert_equal('Dwight Yoakam', first.artist)
79
+ assert_equal('0fb711af-c7ba-4bdc-b0b6-b8495fc0a590', first.artist_mbid)
80
+ assert_equal('The Very Best of Dwight Yoakam', first.name)
81
+ assert_equal('b6a051b4-1a1e-4c33-a1e5-0ea6e920a13f', first.mbid)
82
+ assert_equal('560', first.playcount)
83
+ assert_equal('1', first.rank)
84
+ assert_equal('http://www.last.fm/music/Dwight+Yoakam/The+Very+Best+of+Dwight+Yoakam', first.url)
85
+ assert_equal('http://userserve-ak.last.fm/serve/34s/8725405.jpg', first.image(:small))
86
+ assert_equal('http://userserve-ak.last.fm/serve/64s/8725405.jpg', first.image(:medium))
87
+ assert_equal('http://userserve-ak.last.fm/serve/126/8725405.jpg', first.image(:large))
88
+ end
89
+
90
+ test 'should be able to get top tracks' do
91
+ assert_equal(50, @user.top_tracks.size)
92
+ first = @user.top_tracks.first
93
+ assert_equal("Probably Wouldn't Be This Way", first.name)
94
+ assert_equal('LeAnn Rimes', first.artist)
95
+ assert_equal('9092d8e1-9b38-4372-a96d-000b8561a8bc', first.artist_mbid)
96
+ assert_equal("", first.mbid)
97
+ assert_equal('83', first.playcount)
98
+ assert_equal('1', first.rank)
99
+ assert_equal('http://www.last.fm/music/LeAnn+Rimes/_/Probably+Wouldn%27t+Be+This+Way', first.url)
100
+ end
101
+
102
+ test 'should be able to get top tags' do
103
+ assert_equal(12, @user.top_tags.size)
104
+ first = @user.top_tags.first
105
+ assert_equal("country", first.name)
106
+ assert_equal("7", first.count)
107
+ assert_equal("http://www.last.fm/tag/country", first.url)
108
+ end
109
+
110
+ # not implemented
111
+ test 'should be able to get top tags for artist' do
112
+ end
113
+ # not implemented
114
+ test 'should be able to get top tags for album' do
115
+ end
116
+ # not implemented
117
+ test 'should be able to get top tags for track' do
118
+ end
119
+
120
+ test 'should have friends' do
121
+ assert_equal(17, @user.friends.size)
122
+ first = @user.friends.first
123
+ assert_equal('mayorcj', first.username)
124
+ assert_equal('http://www.last.fm/user/mayorcj', first.url)
125
+ assert_equal('http://userserve-ak.last.fm/serve/34/37841973.jpg', first.avatar)
126
+ end
127
+
128
+ test 'should have neighbours' do
129
+ assert_equal(50, @user.neighbours.size)
130
+ first = @user.neighbours.first
131
+ assert_equal('AustinFarrellR', first.username)
132
+ assert_equal('http://www.last.fm/user/AustinFarrellR', first.url)
133
+ assert_equal('http://userserve-ak.last.fm/serve/34/24713961.jpg', first.avatar)
134
+ end
135
+
136
+ test 'should have recent tracks' do
137
+ assert_equal(10, @user.recent_tracks.size)
138
+ first = @user.recent_tracks.first
139
+ assert_equal('Airstream Song', first.name)
140
+ assert_equal('Miranda Lambert', first.artist)
141
+ assert_equal('4eca1aa0-c79f-481b-af8a-4a2d6c41aa5c', first.artist_mbid)
142
+ assert_equal('', first.mbid)
143
+ assert_equal('4eca1aa0-c79f-481b-af8a-4a2d6c41aa5c', first.album_mbid)
144
+ assert_equal('Revolution', first.album)
145
+ assert_equal('http://www.last.fm/music/Miranda+Lambert/_/Airstream+Song', first.url)
146
+ assert_equal(Time.mktime(2010, 6, 19, 17, 6, 00), first.date)
147
+ assert_equal('1276967182', first.date_uts)
148
+ end
149
+
150
+ test 'should have recent loved tracks' do
151
+ assert_equal(50, @user.recent_loved_tracks.size)
152
+ first = @user.recent_loved_tracks.first
153
+ assert_equal('Don\'t Stop Believin\' (Glee Cast Version)', first.name)
154
+ assert_equal('Glee Cast', first.artist)
155
+ assert_equal('50549203-9602-451c-b49f-ff031ba8635c', first.artist_mbid)
156
+ assert_equal('', first.mbid)
157
+ assert_equal('http://www.last.fm/music/Glee+Cast/_/Don%27t+Stop+Believin%27+%28Glee+Cast+Version%29', first.url)
158
+ assert_equal(Time.mktime(2009, 5, 27, 14, 36, 00), first.date)
159
+ assert_equal('1243434966', first.date_uts)
160
+ end
161
+
162
+ test 'should have recommendations is deprecated' do
163
+ assert_equal(0, @user.recommendations.size)
164
+ end
165
+
166
+ test 'should have artist recommendations' do
167
+ first = @user.recommended_artists("token").first
168
+ assert_equal('Virginia Jetzt!', first.name)
169
+ assert_equal('433d544f-d6c6-4c79-aefd-6f4c7918e5fe', first.mbid)
170
+ assert_equal('http://www.last.fm/music/Virginia+Jetzt%21', first.url)
171
+ end
172
+
173
+ test 'should have charts' do
174
+ assert_equal(229, @user.charts.size)
175
+ first = @user.charts.first
176
+ assert_equal(1134302403, first.from)
177
+ assert_equal(1134907203, first.to)
178
+ end
179
+
180
+ test 'should have weekly artist chart' do
181
+ chart = @user.weekly_artist_chart
182
+ assert_equal(3, chart.size)
183
+ first = chart.first
184
+ assert_equal('Glee Cast', first.name)
185
+ assert_equal('6e0ae159-8449-4262-bba5-18ec87fa529f', first.mbid)
186
+ assert_equal('1', first.chartposition)
187
+ assert_equal('45', first.playcount)
188
+ assert_equal('http://www.last.fm/music/Glee+Cast', first.url)
189
+ end
190
+
191
+ test 'should have weekly artist chart for past weeks' do
192
+ chart = @user.weekly_artist_chart(1138536002, 1139140802)
193
+ assert_equal(33, chart.size)
194
+ first = chart.first
195
+ assert_equal('Jenny Lewis with The Watson Twins', first.name)
196
+ assert_equal('4b179fe2-dfa5-40b1-b6db-b56dbc3b5f09', first.mbid)
197
+ assert_equal('1', first.chartposition)
198
+ assert_equal('48', first.playcount)
199
+ assert_equal('http://www.last.fm/music/Jenny+Lewis+with+The+Watson+Twins', first.url)
200
+ end
201
+
202
+ test 'should have weekly album chart' do
203
+ chart = @user.weekly_album_chart
204
+ assert_equal(4, chart.size)
205
+ first = chart.first
206
+ assert_equal('Brad Mehldau', first.artist)
207
+ assert_equal('b7723b3f-9a35-438d-bc42-8ad8b5e027ae', first.artist_mbid)
208
+ assert_equal("Highway Rider", first.name)
209
+ assert_equal('', first.mbid)
210
+ assert_equal('1', first.chartposition)
211
+ assert_equal('15', first.playcount)
212
+ assert_equal('http://www.last.fm/music/Brad+Mehldau/Highway+Rider', first.url)
213
+ end
214
+
215
+ test 'should have weekly album chart for past weeks' do
216
+ chart = @user.weekly_album_chart(1138536002, 1139140802)
217
+ assert_equal(20, chart.size)
218
+ first = chart.first
219
+ assert_equal('Jewel', first.artist)
220
+ assert_equal('abae8575-ec8a-4736-abc3-1ad5093a68aa', first.artist_mbid)
221
+ assert_equal("0304", first.name)
222
+ assert_equal('52b3f067-9d82-488c-9747-6d608d9b9486', first.mbid)
223
+ assert_equal('1', first.chartposition)
224
+ assert_equal('13', first.playcount)
225
+ assert_equal('http://www.last.fm/music/Jewel/0304', first.url)
226
+ end
227
+
228
+ test 'should have track album chart' do
229
+ chart = @user.weekly_track_chart
230
+ assert_equal(42, chart.size)
231
+ first = chart.first
232
+ assert_equal('Glee Cast', first.artist)
233
+ assert_equal('3ac2a4a2-52b3-498b-bbc8-31443c68dfe0', first.artist_mbid)
234
+ assert_equal('Gives You Hell (Glee Cast Version)', first.name)
235
+ assert_equal('', first.mbid)
236
+ assert_equal('1', first.chartposition)
237
+ assert_equal('5', first.playcount)
238
+ assert_equal('http://www.last.fm/music/+noredirect/Glee+Cast/_/Gives+You+Hell+%28Glee+Cast+Version%29', first.url)
239
+ end
240
+
241
+ test 'should have weekly track chart for past weeks' do
242
+ chart = @user.weekly_track_chart(1138536002, 1139140802)
243
+ assert_equal(88, chart.size)
244
+ first = chart.first
245
+ assert_equal('Natasha Bedingfield', first.artist)
246
+ assert_equal('8b477559-946e-4ef2-9fe1-446cff8fdd79', first.artist_mbid)
247
+ assert_equal('Unwritten', first.name)
248
+ assert_equal('', first.mbid)
249
+ assert_equal('1', first.chartposition)
250
+ assert_equal('8', first.playcount)
251
+ assert_equal('http://www.last.fm/music/Natasha+Bedingfield/_/Unwritten', first.url)
252
+ end
253
+
254
+ test 'should get recommendated events' do
255
+ user = Rockstar::User.new('bodot')
256
+ events = user.events("token")
257
+
258
+ first = events.first
259
+ assert_equal(7, events.size)
260
+ assert_equal("Cityfestival (gamescom)", first.title)
261
+ assert_equal(13, first.artists.size)
262
+ assert_equal("2raumwohnung", first.artists.first)
263
+ assert_equal(1, first.headliners.size)
264
+ assert_equal("2raumwohnung", first.headliners.first)
265
+ assert_equal(Time.local(2010, 8, 20, 17, 50, 1), first.start_date)
266
+ assert_equal(Time.local(2010, 8, 22, 17, 50, 1), first.end_date)
267
+ assert(first.description.length >= 814)
268
+ assert_equal(200, first.attendance)
269
+ assert_equal(0, first.reviews)
270
+ assert_equal("lastfm:event=1575046", first.tag)
271
+ assert_equal("http://www.last.fm/festival/1575046+Cityfestival+%28gamescom%29", first.url)
272
+ assert_equal("http://www.gamescom.de", first.website)
273
+ assert_equal(false, first.cancelled)
274
+ assert_equal(0, first.tickets.size)
275
+ assert_equal(["indie", "german"], first.tags)
276
+ assert_equal("http://userserve-ak.last.fm/serve/34/3608276.jpg", first.images["small"])
277
+ assert_equal("http://userserve-ak.last.fm/serve/64/3608276.jpg", first.images["medium"])
278
+ assert_equal("http://userserve-ak.last.fm/serve/126/3608276.jpg", first.images["large"])
279
+ assert_equal("http://userserve-ak.last.fm/serve/252/3608276.jpg", first.images["extralarge"])
280
+
281
+ assert_equal("Innenstadt", first.venue.name)
282
+
283
+ assert_equal("Köln", first.venue.city.mb_chars)
284
+ assert_equal("Germany", first.venue.country)
285
+ assert_equal("Street", first.venue.street)
286
+ assert_equal("12345", first.venue.postalcode)
287
+ assert_equal("50.929442", first.venue.lat)
288
+ assert_equal("6.961012", first.venue.long)
289
+ assert_equal("http://www.last.fm/venue/8921690+Innenstadt", first.venue.url)
290
+ assert_equal("http://example.com", first.venue.website)
291
+ assert_equal("+49 110", first.venue.phonenumber)
292
+ assert_equal("small", first.venue.images["small"])
293
+ assert_equal("medium", first.venue.images["medium"])
294
+ assert_equal("large", first.venue.images["large"])
295
+ assert_equal("extralarge", first.venue.images["extralarge"])
296
+
297
+ end
298
+
299
+ end