jonaustin-rockstar 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. checksums.yaml +7 -0
  2. data/.travis.yml +8 -0
  3. data/Gemfile +10 -0
  4. data/Gemfile.lock +62 -0
  5. data/History.txt +6 -0
  6. data/MIT-LICENSE +19 -0
  7. data/Manifest +72 -0
  8. data/README.md +173 -0
  9. data/Rakefile +32 -0
  10. data/VERSION +1 -0
  11. data/examples/.gitignore +1 -0
  12. data/examples/album.rb +16 -0
  13. data/examples/artist.rb +25 -0
  14. data/examples/geo.rb +60 -0
  15. data/examples/lastfm.yml_example +3 -0
  16. data/examples/scrobble.rb +45 -0
  17. data/examples/tag.rb +20 -0
  18. data/examples/track.rb +14 -0
  19. data/examples/user.rb +18 -0
  20. data/lib/rockstar.rb +46 -0
  21. data/lib/rockstar/album.rb +104 -0
  22. data/lib/rockstar/artist.rb +183 -0
  23. data/lib/rockstar/auth.rb +38 -0
  24. data/lib/rockstar/base.rb +48 -0
  25. data/lib/rockstar/chart.rb +31 -0
  26. data/lib/rockstar/event.rb +73 -0
  27. data/lib/rockstar/geo.rb +47 -0
  28. data/lib/rockstar/library.rb +13 -0
  29. data/lib/rockstar/metro.rb +26 -0
  30. data/lib/rockstar/rest.rb +66 -0
  31. data/lib/rockstar/session.rb +19 -0
  32. data/lib/rockstar/tag.rb +100 -0
  33. data/lib/rockstar/track.rb +265 -0
  34. data/lib/rockstar/user.rb +205 -0
  35. data/lib/rockstar/venue.rb +59 -0
  36. data/lib/rockstar/version.rb +3 -0
  37. data/rockstar.gemspec +176 -0
  38. data/test/fixtures/xml/album/getinfo_album_Radio_Retalation_artist_Thievery_Corporation.xml +21 -0
  39. data/test/fixtures/xml/album/getinfo_album_Some_Hearts_artist_Carrie_Underwood.xml +63 -0
  40. data/test/fixtures/xml/artist/getevents_artist_Metallica.xml +1064 -0
  41. data/test/fixtures/xml/artist/getimages_artist_Metallica_page_2.xml +1074 -0
  42. data/test/fixtures/xml/artist/getinfo_artist_Metallica.xml +115 -0
  43. data/test/fixtures/xml/artist/getinfo_mbid_65f4f0c5-ef9e-490c-aee3-909e7ae6b2ab.xml +115 -0
  44. data/test/fixtures/xml/artist/getsimilar_artist_Metallica.xml +1203 -0
  45. data/test/fixtures/xml/artist/gettopalbums_artist_Metallica.xml +704 -0
  46. data/test/fixtures/xml/artist/gettopfans_artist_Metallica.xml +504 -0
  47. data/test/fixtures/xml/artist/gettoptags_artist_Metallica.xml +403 -0
  48. data/test/fixtures/xml/artist/gettoptracks_artist_Metallica.xml +800 -0
  49. data/test/fixtures/xml/geo/getevents_location_london.xml +531 -0
  50. data/test/fixtures/xml/geo/getmetros_country_germany.xml +44 -0
  51. data/test/fixtures/xml/geo/gettopartists_country_spain_limit_50_page_.xml +561 -0
  52. data/test/fixtures/xml/geo/gettoptracks_country_spain_limit_50_page_.xml +1004 -0
  53. data/test/fixtures/xml/library/getalbums_user_jnunemaker.xml +704 -0
  54. data/test/fixtures/xml/library/getartists_user_jnunemaker.xml +554 -0
  55. data/test/fixtures/xml/tag/gettopalbums_tag_rock.xml +654 -0
  56. data/test/fixtures/xml/tag/gettopartists_tag_rock.xml +504 -0
  57. data/test/fixtures/xml/tag/gettoptags.xml +1253 -0
  58. data/test/fixtures/xml/tag/gettoptracks_tag_rock.xml +704 -0
  59. data/test/fixtures/xml/track/getinfo_artist_Carrie_Underwood_track_Before_He_Cheats.xml +55 -0
  60. data/test/fixtures/xml/track/getinfo_artist_Karrie_Underwood_track_Before_He_Cheats.xml +55 -0
  61. data/test/fixtures/xml/track/getsimilar_artist_Carrie_Underwood_limit_10_track_Before_He_Cheats.xml +185 -0
  62. data/test/fixtures/xml/track/gettopfans_artist_Carrie_Underwood_track_Before_He_Cheats.xml +504 -0
  63. data/test/fixtures/xml/track/gettoptags_artist_Carrie_Underwood_track_Before_He_Cheats.xml +403 -0
  64. data/test/fixtures/xml/track/gettoptags_artist_Carrie_Underwood_track_Wasted.xml +405 -0
  65. data/test/fixtures/xml/track/love_artist_Carrie_Underwood_sk_tag_track_Before_He_Cheats.xml +2 -0
  66. data/test/fixtures/xml/track/updatenowplaying_artist_Carrie_Underwood_sk_tag_track_Before_He_Cheats.xml +10 -0
  67. data/test/fixtures/xml/user/getevents_sk_token_user_bodot.xml +513 -0
  68. data/test/fixtures/xml/user/getfriends_user_jnunemaker.xml +173 -0
  69. data/test/fixtures/xml/user/getinfo_user_jnunemaker.xml +22 -0
  70. data/test/fixtures/xml/user/getinfo_user_oaknd1.xml +22 -0
  71. data/test/fixtures/xml/user/getinfo_user_wharle.xml +22 -0
  72. data/test/fixtures/xml/user/getlovedtracks_user_jnunemaker.xml +775 -0
  73. data/test/fixtures/xml/user/getneighbours_user_jnunemaker.xml +503 -0
  74. data/test/fixtures/xml/user/getrecenttracks_user_jnunemaker.xml +133 -0
  75. data/test/fixtures/xml/user/getrecommendedartists_sk_token_user_jnunemaker.xml +553 -0
  76. data/test/fixtures/xml/user/gettopalbums_user_jnunemaker.xml +704 -0
  77. data/test/fixtures/xml/user/gettopartists_period_3month_user_jnunemaker.xml +710 -0
  78. data/test/fixtures/xml/user/gettopartists_period_overall_user_jnunemaker.xml +554 -0
  79. data/test/fixtures/xml/user/gettoptags_user_jnunemaker.xml +63 -0
  80. data/test/fixtures/xml/user/gettoptracks_user_jnunemaker.xml +750 -0
  81. data/test/fixtures/xml/user/getweeklyalbumchart_from_1138536002_to_1139140802_user_jnunemaker.xml +143 -0
  82. data/test/fixtures/xml/user/getweeklyalbumchart_from__to__user_jnunemaker.xml +31 -0
  83. data/test/fixtures/xml/user/getweeklyartistchart_from_1138536002_to_1139140802_user_jnunemaker.xml +201 -0
  84. data/test/fixtures/xml/user/getweeklyartistchart_from__to__user_jnunemaker.xml +21 -0
  85. data/test/fixtures/xml/user/getweeklychartlist_user_jnunemaker.xml +232 -0
  86. data/test/fixtures/xml/user/getweeklytrackchart_from_1138536002_to_1139140802_user_jnunemaker.xml +883 -0
  87. data/test/fixtures/xml/user/getweeklytrackchart_from__to__user_jnunemaker.xml +423 -0
  88. data/test/fixtures/xml/venue/getevents_venue_8807850.xml +280 -0
  89. data/test/fixtures/xml/venue/search_country__limit__page__venue_country_DE_venue_cotton.xml +72 -0
  90. data/test/mocks/rest.rb +50 -0
  91. data/test/test_helper.rb +18 -0
  92. data/test/unit/test_album.rb +76 -0
  93. data/test/unit/test_artist.rb +123 -0
  94. data/test/unit/test_chart.rb +35 -0
  95. data/test/unit/test_geo.rb +51 -0
  96. data/test/unit/test_library.rb +65 -0
  97. data/test/unit/test_rockstar.rb +15 -0
  98. data/test/unit/test_tag.rb +57 -0
  99. data/test/unit/test_track.rb +93 -0
  100. data/test/unit/test_user.rb +309 -0
  101. data/test/unit/test_venue.rb +20 -0
  102. metadata +243 -0
@@ -0,0 +1,15 @@
1
+ require File.expand_path('../../test_helper.rb', __FILE__)
2
+
3
+ class TestRockstar < Test::Unit::TestCase
4
+ test 'should accept strings' do
5
+ Rockstar.lastfm = {"api_key" => "1234567890", "api_secret" => "0987654321"}
6
+ assert_equal(Rockstar.lastfm_api_key, "1234567890")
7
+ assert_equal(Rockstar.lastfm_api_secret, "0987654321")
8
+ end
9
+
10
+ test 'should accept symbols' do
11
+ Rockstar.lastfm = {:api_key => "1234567890", :api_secret => "0987654321"}
12
+ assert_equal(Rockstar.lastfm_api_key, "1234567890")
13
+ assert_equal(Rockstar.lastfm_api_secret, "0987654321")
14
+ end
15
+ 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,93 @@
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
+ @track1 = Rockstar::Track.new('Karrie Underwood', 'Before He Cheats')
8
+ end
9
+
10
+ test 'should require the artist name' do
11
+ assert_raises(ArgumentError) { Rockstar::Track.new('', 'Before He Cheats') }
12
+ end
13
+
14
+ test 'should require the track name' do
15
+ assert_raises(ArgumentError) { Rockstar::Track.new('Carrie Underwood', '') }
16
+ end
17
+
18
+ test "should know the artist" do
19
+ assert_equal('Carrie Underwood', @track.artist)
20
+ end
21
+
22
+ test 'should know the name' do
23
+ assert_equal('Before He Cheats', @track.name)
24
+ end
25
+
26
+ test 'should be able to load track info' do
27
+ @track.load_info
28
+ @track1.load_info
29
+ assert_equal('http://www.last.fm/music/Carrie+Underwood/_/Before+He+Cheats', @track.url)
30
+ assert_equal('1040848', @track.playcount)
31
+ assert_equal(false, @track.now_playing?)
32
+ assert_equal(true, @track1.now_playing?)
33
+ assert_match(/named the 2007 Single of the Year by the Country Music Association/, @track.summary)
34
+ end
35
+
36
+ test 'should be able to request detailed album info on initialize' do
37
+ track = Rockstar::Track.new('Carrie Underwood', 'Before He Cheats', :include_info => true)
38
+ assert_equal('Carrie Underwood', track.artist)
39
+ assert_equal('http://www.last.fm/music/Carrie+Underwood/_/Before+He+Cheats', track.url)
40
+ assert_equal('1040848', track.playcount)
41
+ assert_match(/named the 2007 Single of the Year by the Country Music Association/, track.summary)
42
+ end
43
+
44
+ test 'should have albums' do
45
+ assert_equal(1, @track.albums.size)
46
+ assert_equal('Some Hearts', @track.albums.first.name)
47
+ assert_equal('http://www.last.fm/music/Carrie+Underwood/Some+Hearts', @track.albums.first.url)
48
+ assert_equal('a33b9822-9f09-4e19-9d6e-e05af85c727b', @track.albums.first.mbid)
49
+ end
50
+
51
+ test 'should have fans' do
52
+ assert_equal(50, @track.fans.size)
53
+ assert_equal('chelseaf89', @track.fans.first.username)
54
+ assert_equal('http://www.last.fm/user/chelseaf89', @track.fans.first.url)
55
+ assert_equal('http://userserve-ak.last.fm/serve/34/41303325.jpg', @track.fans.first.avatar)
56
+ assert_equal('5000000', @track.fans.first.weight)
57
+ end
58
+
59
+ test 'should have top tags' do
60
+ assert_equal(100, @track.tags.size)
61
+ assert_equal('country', @track.tags.first.name)
62
+ assert_equal('100', @track.tags.first.count)
63
+ assert_equal('http://www.last.fm/tag/country', @track.tags.first.url)
64
+ end
65
+
66
+ test 'should have similar tracks' do
67
+ tracks = @track.similar
68
+ assert tracks.size > 0, "There should be similar tracks"
69
+ tracks.each{|t| assert_instance_of(Rockstar::Track, t, "Returned objects should all be Track objects")}
70
+ assert tracks.first.tags.map{|t|t.name.downcase}.include?("country"), "The first similar track should be tagged with 'country'"
71
+ end
72
+
73
+ test 'can love tracks' do
74
+ assert_equal('ok', @track.love("tag"))
75
+ end
76
+
77
+ test 'raise missing parameter error in scrobble' do
78
+ assert_raises(ArgumentError) { Rockstar::Track.scrobble() }
79
+ end
80
+
81
+ test 'can scrobble tracks' do
82
+ assert_equal('ok', @track.scrobble(Time.utc(2010,10,10,8,10), 'tag'))
83
+ end
84
+
85
+ test 'raise missing parameter error in update now playing' do
86
+ assert_raises(ArgumentError) { Rockstar::Track.updateNowPlaying() }
87
+ end
88
+
89
+ test 'can send current playing track' do
90
+ assert_equal('ok', @track.updateNowPlaying(Time.utc(2010,10,10,8,10), 'tag'))
91
+ end
92
+
93
+ end
@@ -0,0 +1,309 @@
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 a user's top artists for a period of time" do
76
+ last_3_month_artists = @user.top_artists( true, :period => "3month" )
77
+ assert_equal(50, last_3_month_artists.size)
78
+
79
+ first = @user.top_artists.first
80
+ assert_equal('Florence + The Machine', first.name)
81
+ assert_equal('', first.mbid)
82
+ assert_equal('341', first.playcount)
83
+ assert_equal('1', first.rank)
84
+ assert_equal('http://www.last.fm/music/Florence%2B%252B%2BThe%2BMachine', first.url)
85
+ assert_equal('http://userserve-ak.last.fm/serve/34/50373889.png', first.thumbnail)
86
+ assert_equal('http://userserve-ak.last.fm/serve/64/50373889.png', first.image)
87
+ end
88
+
89
+ test 'should be able to get top albums' do
90
+ assert_equal(50, @user.top_albums.size)
91
+ first = @user.top_albums.first
92
+ assert_equal('Dwight Yoakam', first.artist)
93
+ assert_equal('0fb711af-c7ba-4bdc-b0b6-b8495fc0a590', first.artist_mbid)
94
+ assert_equal('The Very Best of Dwight Yoakam', first.name)
95
+ assert_equal('b6a051b4-1a1e-4c33-a1e5-0ea6e920a13f', first.mbid)
96
+ assert_equal('560', first.playcount)
97
+ assert_equal('1', first.rank)
98
+ assert_equal('http://www.last.fm/music/Dwight+Yoakam/The+Very+Best+of+Dwight+Yoakam', first.url)
99
+ assert_equal('http://userserve-ak.last.fm/serve/34s/8725405.jpg', first.image(:small))
100
+ assert_equal('http://userserve-ak.last.fm/serve/64s/8725405.jpg', first.image(:medium))
101
+ assert_equal('http://userserve-ak.last.fm/serve/126/8725405.jpg', first.image(:large))
102
+ end
103
+
104
+ test 'should be able to get top tracks' do
105
+ assert_equal(50, @user.top_tracks.size)
106
+ first = @user.top_tracks.first
107
+ assert_equal("Probably Wouldn't Be This Way", first.name)
108
+ assert_equal('LeAnn Rimes', first.artist)
109
+ assert_equal('9092d8e1-9b38-4372-a96d-000b8561a8bc', first.artist_mbid)
110
+ assert_equal("", first.mbid)
111
+ assert_equal('83', first.playcount)
112
+ assert_equal('1', first.rank)
113
+ assert_equal('http://www.last.fm/music/LeAnn+Rimes/_/Probably+Wouldn%27t+Be+This+Way', first.url)
114
+ end
115
+
116
+ test 'should be able to get top tags' do
117
+ assert_equal(12, @user.top_tags.size)
118
+ first = @user.top_tags.first
119
+ assert_equal("country", first.name)
120
+ assert_equal("7", first.count)
121
+ assert_equal("http://www.last.fm/tag/country", first.url)
122
+ end
123
+
124
+ # not implemented
125
+ test 'should be able to get top tags for artist' do
126
+ end
127
+ # not implemented
128
+ test 'should be able to get top tags for album' do
129
+ end
130
+ # not implemented
131
+ test 'should be able to get top tags for track' do
132
+ end
133
+
134
+ test 'should have friends' do
135
+ assert_equal(17, @user.friends.size)
136
+ first = @user.friends.first
137
+ assert_equal('mayorcj', first.username)
138
+ assert_equal('http://www.last.fm/user/mayorcj', first.url)
139
+ assert_equal('http://userserve-ak.last.fm/serve/34/37841973.jpg', first.avatar)
140
+ end
141
+
142
+ test 'should have neighbours' do
143
+ assert_equal(50, @user.neighbours.size)
144
+ first = @user.neighbours.first
145
+ assert_equal('AustinFarrellR', first.username)
146
+ assert_equal('http://www.last.fm/user/AustinFarrellR', first.url)
147
+ assert_equal('http://userserve-ak.last.fm/serve/34/24713961.jpg', first.avatar)
148
+ end
149
+
150
+ test 'should have recent tracks' do
151
+ assert_equal(10, @user.recent_tracks.size)
152
+ first = @user.recent_tracks.first
153
+ assert_equal('Airstream Song', first.name)
154
+ assert_equal('Miranda Lambert', first.artist)
155
+ assert_equal('4eca1aa0-c79f-481b-af8a-4a2d6c41aa5c', first.artist_mbid)
156
+ assert_equal('', first.mbid)
157
+ assert_equal('4eca1aa0-c79f-481b-af8a-4a2d6c41aa5c', first.album_mbid)
158
+ assert_equal('Revolution', first.album)
159
+ assert_equal('http://www.last.fm/music/Miranda+Lambert/_/Airstream+Song', first.url)
160
+ assert_equal(Time.mktime(2010, 6, 19, 17, 6, 00), first.date)
161
+ assert_equal('1276967182', first.date_uts)
162
+ end
163
+
164
+ test 'should have recent loved tracks' do
165
+ assert_equal(50, @user.recent_loved_tracks.size)
166
+ first = @user.recent_loved_tracks.first
167
+ assert_equal('Don\'t Stop Believin\' (Glee Cast Version)', first.name)
168
+ assert_equal('Glee Cast', first.artist)
169
+ assert_equal('50549203-9602-451c-b49f-ff031ba8635c', first.artist_mbid)
170
+ assert_equal('', first.mbid)
171
+ assert_equal('http://www.last.fm/music/Glee+Cast/_/Don%27t+Stop+Believin%27+%28Glee+Cast+Version%29', first.url)
172
+ assert_equal(Time.mktime(2009, 5, 27, 14, 36, 00), first.date)
173
+ assert_equal('1243434966', first.date_uts)
174
+ end
175
+
176
+ test 'should have artist recommendations' do
177
+ first = @user.recommended_artists("token").first
178
+ assert_equal('Virginia Jetzt!', first.name)
179
+ assert_equal('433d544f-d6c6-4c79-aefd-6f4c7918e5fe', first.mbid)
180
+ assert_equal('http://www.last.fm/music/Virginia+Jetzt%21', first.url)
181
+ end
182
+
183
+ test 'should have charts' do
184
+ assert_equal(229, @user.charts.size)
185
+ first = @user.charts.first
186
+ assert_equal(1134302403, first.from)
187
+ assert_equal(1134907203, first.to)
188
+ end
189
+
190
+ test 'should have weekly artist chart' do
191
+ chart = @user.weekly_artist_chart
192
+ assert_equal(3, chart.size)
193
+ first = chart.first
194
+ assert_equal('Glee Cast', first.name)
195
+ assert_equal('6e0ae159-8449-4262-bba5-18ec87fa529f', first.mbid)
196
+ assert_equal('1', first.chartposition)
197
+ assert_equal('45', first.playcount)
198
+ assert_equal('http://www.last.fm/music/Glee+Cast', first.url)
199
+ end
200
+
201
+ test 'should have weekly artist chart for past weeks' do
202
+ chart = @user.weekly_artist_chart(1138536002, 1139140802)
203
+ assert_equal(33, chart.size)
204
+ first = chart.first
205
+ assert_equal('Jenny Lewis with The Watson Twins', first.name)
206
+ assert_equal('4b179fe2-dfa5-40b1-b6db-b56dbc3b5f09', first.mbid)
207
+ assert_equal('1', first.chartposition)
208
+ assert_equal('48', first.playcount)
209
+ assert_equal('http://www.last.fm/music/Jenny+Lewis+with+The+Watson+Twins', first.url)
210
+ end
211
+
212
+ test 'should have weekly album chart' do
213
+ chart = @user.weekly_album_chart
214
+ assert_equal(4, chart.size)
215
+ first = chart.first
216
+ assert_equal('Brad Mehldau', first.artist)
217
+ assert_equal('b7723b3f-9a35-438d-bc42-8ad8b5e027ae', first.artist_mbid)
218
+ assert_equal("Highway Rider", first.name)
219
+ assert_equal('', first.mbid)
220
+ assert_equal('1', first.chartposition)
221
+ assert_equal('15', first.playcount)
222
+ assert_equal('http://www.last.fm/music/Brad+Mehldau/Highway+Rider', first.url)
223
+ end
224
+
225
+ test 'should have weekly album chart for past weeks' do
226
+ chart = @user.weekly_album_chart(1138536002, 1139140802)
227
+ assert_equal(20, chart.size)
228
+ first = chart.first
229
+ assert_equal('Jewel', first.artist)
230
+ assert_equal('abae8575-ec8a-4736-abc3-1ad5093a68aa', first.artist_mbid)
231
+ assert_equal("0304", first.name)
232
+ assert_equal('52b3f067-9d82-488c-9747-6d608d9b9486', first.mbid)
233
+ assert_equal('1', first.chartposition)
234
+ assert_equal('13', first.playcount)
235
+ assert_equal('http://www.last.fm/music/Jewel/0304', first.url)
236
+ end
237
+
238
+ test 'should have track album chart' do
239
+ chart = @user.weekly_track_chart
240
+ assert_equal(42, chart.size)
241
+ first = chart.first
242
+ assert_equal('Glee Cast', first.artist)
243
+ assert_equal('3ac2a4a2-52b3-498b-bbc8-31443c68dfe0', first.artist_mbid)
244
+ assert_equal('Gives You Hell (Glee Cast Version)', first.name)
245
+ assert_equal('', first.mbid)
246
+ assert_equal('1', first.chartposition)
247
+ assert_equal('5', first.playcount)
248
+ assert_equal('http://www.last.fm/music/+noredirect/Glee+Cast/_/Gives+You+Hell+%28Glee+Cast+Version%29', first.url)
249
+ end
250
+
251
+ test 'should have weekly track chart for past weeks' do
252
+ chart = @user.weekly_track_chart(1138536002, 1139140802)
253
+ assert_equal(88, chart.size)
254
+ first = chart.first
255
+ assert_equal('Natasha Bedingfield', first.artist)
256
+ assert_equal('8b477559-946e-4ef2-9fe1-446cff8fdd79', first.artist_mbid)
257
+ assert_equal('Unwritten', first.name)
258
+ assert_equal('', first.mbid)
259
+ assert_equal('1', first.chartposition)
260
+ assert_equal('8', first.playcount)
261
+ assert_equal('http://www.last.fm/music/Natasha+Bedingfield/_/Unwritten', first.url)
262
+ end
263
+
264
+ test 'should get recommendated events' do
265
+ user = Rockstar::User.new('bodot')
266
+ events = user.events("token")
267
+
268
+ first = events.first
269
+ assert_equal(7, events.size)
270
+ assert_equal("Cityfestival (gamescom)", first.title)
271
+ assert_equal(13, first.artists.size)
272
+ assert_equal("2raumwohnung", first.artists.first)
273
+ assert_equal(1, first.headliners.size)
274
+ assert_equal("2raumwohnung", first.headliners.first)
275
+ assert_equal(Time.local(2010, 8, 20, 17, 50, 1), first.start_date)
276
+ assert_equal(Time.local(2010, 8, 22, 17, 50, 1), first.end_date)
277
+ assert(first.description.length >= 814)
278
+ assert_equal(200, first.attendance)
279
+ assert_equal(0, first.reviews)
280
+ assert_equal("lastfm:event=1575046", first.tag)
281
+ assert_equal("http://www.last.fm/festival/1575046+Cityfestival+%28gamescom%29", first.url)
282
+ assert_equal("http://www.gamescom.de", first.website)
283
+ assert_equal(false, first.cancelled)
284
+ assert_equal(0, first.tickets.size)
285
+ assert_equal(["indie", "german"], first.tags)
286
+ assert_equal("http://userserve-ak.last.fm/serve/34/3608276.jpg", first.images["small"])
287
+ assert_equal("http://userserve-ak.last.fm/serve/64/3608276.jpg", first.images["medium"])
288
+ assert_equal("http://userserve-ak.last.fm/serve/126/3608276.jpg", first.images["large"])
289
+ assert_equal("http://userserve-ak.last.fm/serve/252/3608276.jpg", first.images["extralarge"])
290
+
291
+ assert_equal("Innenstadt", first.venue.name)
292
+
293
+ assert_equal("Köln", first.venue.city.mb_chars)
294
+ assert_equal("Germany", first.venue.country)
295
+ assert_equal("Street", first.venue.street)
296
+ assert_equal("12345", first.venue.postalcode)
297
+ assert_equal("50.929442", first.venue.lat)
298
+ assert_equal("6.961012", first.venue.long)
299
+ assert_equal("http://www.last.fm/venue/8921690+Innenstadt", first.venue.url)
300
+ assert_equal("http://example.com", first.venue.website)
301
+ assert_equal("+49 110", first.venue.phonenumber)
302
+ assert_equal("small", first.venue.images["small"])
303
+ assert_equal("medium", first.venue.images["medium"])
304
+ assert_equal("large", first.venue.images["large"])
305
+ assert_equal("extralarge", first.venue.images["extralarge"])
306
+
307
+ end
308
+
309
+ end