peteforde-scrobbler 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/MIT-LICENSE +19 -0
- data/Manifest +67 -0
- data/README.rdoc +113 -0
- data/Rakefile +36 -0
- data/examples/album.rb +17 -0
- data/examples/artist.rb +13 -0
- data/examples/scrobble.rb +31 -0
- data/examples/tag.rb +11 -0
- data/examples/track.rb +10 -0
- data/examples/user.rb +14 -0
- data/lib/scrobbler.rb +20 -0
- data/lib/scrobbler/album.rb +143 -0
- data/lib/scrobbler/artist.rb +127 -0
- data/lib/scrobbler/base.rb +29 -0
- data/lib/scrobbler/chart.rb +31 -0
- data/lib/scrobbler/playing.rb +49 -0
- data/lib/scrobbler/rest.rb +51 -0
- data/lib/scrobbler/scrobble.rb +66 -0
- data/lib/scrobbler/simpleauth.rb +59 -0
- data/lib/scrobbler/tag.rb +104 -0
- data/lib/scrobbler/track.rb +98 -0
- data/lib/scrobbler/user.rb +192 -0
- data/lib/scrobbler/version.rb +3 -0
- data/scrobbler.gemspec +39 -0
- data/setup.rb +1585 -0
- data/test/fixtures/xml/album/info.xml +70 -0
- data/test/fixtures/xml/artist/fans.xml +18 -0
- data/test/fixtures/xml/artist/similar.xml +39 -0
- data/test/fixtures/xml/artist/topalbums.xml +36 -0
- data/test/fixtures/xml/artist/toptags.xml +18 -0
- data/test/fixtures/xml/artist/toptracks.xml +27 -0
- data/test/fixtures/xml/tag/topalbums.xml +39 -0
- data/test/fixtures/xml/tag/topartists.xml +39 -0
- data/test/fixtures/xml/tag/toptags.xml +252 -0
- data/test/fixtures/xml/tag/toptracks.xml +30 -0
- data/test/fixtures/xml/track/fans.xml +28 -0
- data/test/fixtures/xml/track/toptags.xml +33 -0
- data/test/fixtures/xml/user/friends.xml +21 -0
- data/test/fixtures/xml/user/neighbours.xml +18 -0
- data/test/fixtures/xml/user/profile.xml +12 -0
- data/test/fixtures/xml/user/recentbannedtracks.xml +24 -0
- data/test/fixtures/xml/user/recentlovedtracks.xml +24 -0
- data/test/fixtures/xml/user/recenttracks.xml +27 -0
- data/test/fixtures/xml/user/systemrecs.xml +18 -0
- data/test/fixtures/xml/user/topalbums.xml +42 -0
- data/test/fixtures/xml/user/topartists.xml +30 -0
- data/test/fixtures/xml/user/toptags.xml +18 -0
- data/test/fixtures/xml/user/toptracks.xml +27 -0
- data/test/fixtures/xml/user/weeklyalbumchart.xml +35 -0
- data/test/fixtures/xml/user/weeklyalbumchart_from_1138536002_to_1139140802.xml +35 -0
- data/test/fixtures/xml/user/weeklyartistchart.xml +38 -0
- data/test/fixtures/xml/user/weeklyartistchart_from_1138536002_to_1139140802.xml +59 -0
- data/test/fixtures/xml/user/weeklychartlist.xml +74 -0
- data/test/fixtures/xml/user/weeklytrackchart.xml +35 -0
- data/test/fixtures/xml/user/weeklytrackchart_from_1138536002_to_1139140802.xml +35 -0
- data/test/mocks/rest.rb +50 -0
- data/test/test_helper.rb +17 -0
- data/test/unit/album_test.rb +86 -0
- data/test/unit/artist_test.rb +82 -0
- data/test/unit/chart_test.rb +34 -0
- data/test/unit/playing_test.rb +53 -0
- data/test/unit/scrobble_test.rb +69 -0
- data/test/unit/simpleauth_test.rb +45 -0
- data/test/unit/tag_test.rb +65 -0
- data/test/unit/track_test.rb +42 -0
- data/test/unit/user_test.rb +291 -0
- metadata +177 -0
@@ -0,0 +1,34 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper.rb'
|
2
|
+
|
3
|
+
class TestChart < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@chart = Scrobbler::Chart.new('1108296002', '1108900802')
|
7
|
+
end
|
8
|
+
|
9
|
+
test 'should require from' do
|
10
|
+
assert_raise(ArgumentError) { Scrobbler::Chart.new('', '1108900802') }
|
11
|
+
end
|
12
|
+
|
13
|
+
test 'should require to' do
|
14
|
+
assert_raise(ArgumentError) { Scrobbler::Chart.new('1108296002', '') }
|
15
|
+
end
|
16
|
+
|
17
|
+
test 'should be able to parse to and from that are unix timestamp strings' do
|
18
|
+
chart = Scrobbler::Chart.new('1108296002', '1108900802')
|
19
|
+
assert_equal(1108296002, chart.from)
|
20
|
+
assert_equal(1108900802, chart.to)
|
21
|
+
end
|
22
|
+
|
23
|
+
test 'should be able to parse to and from that are unix timestamp fixnums' do
|
24
|
+
chart = Scrobbler::Chart.new(1108296002, 1108900802)
|
25
|
+
assert_equal(1108296002, chart.from)
|
26
|
+
assert_equal(1108900802, chart.to)
|
27
|
+
end
|
28
|
+
|
29
|
+
test 'should be able to parse to and from that are times' do
|
30
|
+
chart = Scrobbler::Chart.new(Time.at(1108296002), Time.at(1108900802))
|
31
|
+
assert_equal(1108296002, chart.from)
|
32
|
+
assert_equal(1108900802, chart.to)
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper.rb'
|
2
|
+
|
3
|
+
class TestPlaying < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@session_id = '17E61E13454CDD8B68E8D7DEEEDF6170'
|
7
|
+
@now_playing_url = 'http://62.216.251.203:80/nowplaying'
|
8
|
+
@artist = 'Anberlin'
|
9
|
+
@track = 'A Day Late'
|
10
|
+
@album = 'Never Take Friendship Personal'
|
11
|
+
|
12
|
+
@playing = Scrobbler::Playing.new(:session_id => @session_id, :now_playing_url => @now_playing_url,
|
13
|
+
:artist => @artist, :track => @track, :album => @album, :length => 214,
|
14
|
+
:track_number => 5)
|
15
|
+
end
|
16
|
+
|
17
|
+
test 'should require a session id' do
|
18
|
+
assert_raises(ArgumentError) { Scrobbler::Playing.new(
|
19
|
+
:now_playing_url => @now_playing_url, :artist => @artist, :track => @track,
|
20
|
+
:album => @album, :length => 214, :track_number => 5) }
|
21
|
+
end
|
22
|
+
|
23
|
+
test 'should require a now playing url' do
|
24
|
+
assert_raises(ArgumentError) { Scrobbler::Playing.new(
|
25
|
+
:session_id => @session_id, :artist => @artist, :track => @track,
|
26
|
+
:album => @album, :length => 214, :track_number => 5) }
|
27
|
+
end
|
28
|
+
|
29
|
+
test 'should require an artist' do
|
30
|
+
assert_raises(ArgumentError) { Scrobbler::Playing.new(
|
31
|
+
:session_id => @session_id, :now_playing_url => @now_playing_url,
|
32
|
+
:track => @track, :album => @album, :length => 214, :track_number => 5) }
|
33
|
+
end
|
34
|
+
|
35
|
+
test 'should require a track' do
|
36
|
+
assert_raises(ArgumentError) { Scrobbler::Playing.new(
|
37
|
+
:session_id => @session_id, :now_playing_url => @now_playing_url,
|
38
|
+
:artist => @artist, :album => @album, :length => 214, :track_number => 5) }
|
39
|
+
end
|
40
|
+
|
41
|
+
test 'should require a length greater than 30 seconds' do
|
42
|
+
assert_raises(ArgumentError) { Scrobbler::Playing.new(
|
43
|
+
:session_id => @session_id, :now_playing_url => @now_playing_url,
|
44
|
+
:artist => @artist, :track => @track, :album => @album, :length => 29,
|
45
|
+
:track_number => 5) }
|
46
|
+
end
|
47
|
+
|
48
|
+
test 'should submit successfully' do
|
49
|
+
@playing.submit!
|
50
|
+
assert_equal('OK', @playing.status)
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper.rb'
|
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 = Scrobbler::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) { Scrobbler::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) { Scrobbler::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) { Scrobbler::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) { Scrobbler::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) { Scrobbler::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) { Scrobbler::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) { Scrobbler::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) { Scrobbler::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.dirname(__FILE__) + '/../test_helper.rb'
|
2
|
+
|
3
|
+
class TestSimpleAuth < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@auth = Scrobbler::SimpleAuth.new(:user => 'chunky', :password => 'bacon')
|
7
|
+
end
|
8
|
+
|
9
|
+
test 'should require a user' do
|
10
|
+
assert_raises(ArgumentError) { Scrobbler::SimpleAuth.new(:password => 'bacon') }
|
11
|
+
end
|
12
|
+
|
13
|
+
test 'should require a password' do
|
14
|
+
assert_raises(ArgumentError) { Scrobbler::SimpleAuth.new(:user => 'chunky') }
|
15
|
+
end
|
16
|
+
|
17
|
+
test 'should have the right client id' do
|
18
|
+
assert_equal('rbs', @auth.client_id)
|
19
|
+
end
|
20
|
+
|
21
|
+
test 'should have the right version' do
|
22
|
+
assert_equal(Scrobbler::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,65 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper.rb'
|
2
|
+
|
3
|
+
class TestTag < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
@tag = Scrobbler::Tag.new('rock')
|
6
|
+
end
|
7
|
+
|
8
|
+
test 'should be able to find the top tags for the entire system' do
|
9
|
+
assert_equal(249, Scrobbler::Tag.top_tags.size)
|
10
|
+
assert_equal('rock', Scrobbler::Tag.top_tags.first.name)
|
11
|
+
assert_equal('878660', Scrobbler::Tag.top_tags.first.count)
|
12
|
+
assert_equal('http://www.last.fm/tag/rock', Scrobbler::Tag.top_tags.first.url)
|
13
|
+
end
|
14
|
+
|
15
|
+
test 'should require name' do
|
16
|
+
assert_raise(ArgumentError) { Scrobbler::Tag.new('') }
|
17
|
+
end
|
18
|
+
|
19
|
+
test 'should have name' do
|
20
|
+
assert_equal('rock', @tag.name)
|
21
|
+
end
|
22
|
+
|
23
|
+
test 'should have api path' do
|
24
|
+
assert_equal('/1.0/tag/rock', @tag.api_path)
|
25
|
+
end
|
26
|
+
|
27
|
+
test 'should escape api path' do
|
28
|
+
assert_equal('/1.0/tag/rock+and+roll', Scrobbler::Tag.new('rock and roll').api_path)
|
29
|
+
end
|
30
|
+
|
31
|
+
test 'should be able to find top artists for a tag' do
|
32
|
+
assert_equal(6, @tag.top_artists.size)
|
33
|
+
assert_equal('Red Hot Chili Peppers', @tag.top_artists.first.name)
|
34
|
+
assert_equal('5740', @tag.top_artists.first.count)
|
35
|
+
assert_equal('yes', @tag.top_artists.first.streamable)
|
36
|
+
assert_equal('8bfac288-ccc5-448d-9573-c33ea2aa5c30', @tag.top_artists.first.mbid)
|
37
|
+
assert_equal('http://www.last.fm/music/Red+Hot+Chili+Peppers', @tag.top_artists.first.url)
|
38
|
+
assert_equal('http://static3.last.fm/storable/image/184200/small.jpg', @tag.top_artists.first.thumbnail)
|
39
|
+
assert_equal('http://panther1.last.fm/proposedimages/sidebar/6/1274/552019.jpg', @tag.top_artists.first.image)
|
40
|
+
end
|
41
|
+
|
42
|
+
test 'should be able to find top albums for a tag' do
|
43
|
+
assert_equal(3, @tag.top_albums.size)
|
44
|
+
assert_equal('Californication', @tag.top_albums.first.name)
|
45
|
+
assert_equal('Red Hot Chili Peppers', @tag.top_albums.first.artist)
|
46
|
+
assert_equal('8bfac288-ccc5-448d-9573-c33ea2aa5c30', @tag.top_albums.first.artist_mbid)
|
47
|
+
assert_equal('http://www.last.fm/music/Red+Hot+Chili+Peppers/Californication', @tag.top_albums.first.url)
|
48
|
+
assert_equal('http://panther1.last.fm/coverart/50x50/4791.jpg', @tag.top_albums.first.image(:small))
|
49
|
+
assert_equal('http://cdn.last.fm/coverart/130x130/4791.jpg', @tag.top_albums.first.image(:medium))
|
50
|
+
assert_equal('http://cdn.last.fm/coverart/300x300/4791.jpg', @tag.top_albums.first.image(:large))
|
51
|
+
end
|
52
|
+
|
53
|
+
test 'should be able to find top tracks for a tag' do
|
54
|
+
assert_equal(3, @tag.top_tracks.size)
|
55
|
+
first = @tag.top_tracks.first
|
56
|
+
assert_equal('Once Upon a Time', first.name)
|
57
|
+
assert_equal('1076', first.count)
|
58
|
+
assert_equal('no', first.streamable)
|
59
|
+
assert_equal('Frank Zappa', first.artist)
|
60
|
+
assert_equal('e20747e7-55a4-452e-8766-7b985585082d', first.artist_mbid)
|
61
|
+
assert_equal('http://www.last.fm/music/Frank+Zappa/_/Once+Upon+a+Time', first.url)
|
62
|
+
assert_equal('http://ec1.images-amazon.com/images/P/B0000009TN.01._SCMZZZZZZZ_.jpg', first.thumbnail)
|
63
|
+
assert_equal('http://ec1.images-amazon.com/images/P/B0000009TN.01._SCMZZZZZZZ_.jpg', first.image)
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper.rb'
|
2
|
+
|
3
|
+
class TestTrack < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
@track = Scrobbler::Track.new('Carrie Underwood', 'Before He Cheats')
|
6
|
+
end
|
7
|
+
|
8
|
+
test 'should require the artist name' do
|
9
|
+
assert_raises(ArgumentError) { Scrobbler::Track.new('', 'Before He Cheats') }
|
10
|
+
end
|
11
|
+
|
12
|
+
test 'should require the track name' do
|
13
|
+
assert_raises(ArgumentError) { Scrobbler::Track.new('Carrie Underwood', '') }
|
14
|
+
end
|
15
|
+
|
16
|
+
test "should know the artist" do
|
17
|
+
assert_equal('Carrie Underwood', @track.artist)
|
18
|
+
end
|
19
|
+
|
20
|
+
test 'should know the name' do
|
21
|
+
assert_equal('Before He Cheats', @track.name)
|
22
|
+
end
|
23
|
+
|
24
|
+
test 'should have api path' do
|
25
|
+
assert_equal('/1.0/track/Carrie+Underwood/Before+He+Cheats', @track.api_path)
|
26
|
+
end
|
27
|
+
|
28
|
+
test 'should have fans' do
|
29
|
+
assert_equal(5, @track.fans.size)
|
30
|
+
assert_equal('frozenice', @track.fans.first.username)
|
31
|
+
assert_equal('http://www.last.fm/user/frozenice/', @track.fans.first.url)
|
32
|
+
assert_equal('http://panther1.last.fm/avatar/54e8d2cafc363336e15fef0a48d30706.jpg', @track.fans.first.avatar)
|
33
|
+
assert_equal('909', @track.fans.first.weight)
|
34
|
+
end
|
35
|
+
|
36
|
+
test 'should have top tags' do
|
37
|
+
assert_equal(6, @track.tags.size)
|
38
|
+
assert_equal('country', @track.tags.first.name)
|
39
|
+
assert_equal('100', @track.tags.first.count)
|
40
|
+
assert_equal('http://www.last.fm/tag/country', @track.tags.first.url)
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,291 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper.rb'
|
2
|
+
|
3
|
+
class TestUser < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@user = Scrobbler::User.new('jnunemaker')
|
7
|
+
end
|
8
|
+
|
9
|
+
test 'should be able to find one user' do
|
10
|
+
assert_equal(@user.username, Scrobbler::User.find('jnunemaker').username)
|
11
|
+
end
|
12
|
+
|
13
|
+
test 'should be able to find multiple users' do
|
14
|
+
users = Scrobbler::User.find('jnunemaker', 'oaknd1', 'wharle')
|
15
|
+
assert_equal(%w{jnunemaker oaknd1 wharle}, users.collect(&:username))
|
16
|
+
end
|
17
|
+
|
18
|
+
test 'should be able to find multiple users using an array' do
|
19
|
+
users = Scrobbler::User.find(%w{jnunemaker oaknd1 wharle})
|
20
|
+
assert_equal(%w{jnunemaker oaknd1 wharle}, users.collect(&:username))
|
21
|
+
end
|
22
|
+
|
23
|
+
test 'should be able to load profile while finding' do
|
24
|
+
user = Scrobbler::User.find('jnunemaker', :include_profile => true)
|
25
|
+
assert_equal(@user.username, user.username)
|
26
|
+
assert_equal('3017870', user.id)
|
27
|
+
end
|
28
|
+
|
29
|
+
test 'should be able to load profile while finding multiple users' do
|
30
|
+
users = Scrobbler::User.find('jnunemaker', 'oaknd1', 'wharle', :include_profile => true)
|
31
|
+
assert_equal(3, users.size)
|
32
|
+
end
|
33
|
+
|
34
|
+
test 'should require a username' do
|
35
|
+
assert_raise(ArgumentError) { Scrobbler::User.new('') }
|
36
|
+
end
|
37
|
+
|
38
|
+
test 'should have api path' do
|
39
|
+
assert_equal('/1.0/user/jnunemaker', @user.api_path)
|
40
|
+
end
|
41
|
+
|
42
|
+
test 'should know the correct current events addresses' do
|
43
|
+
assert_equal('http://ws.audioscrobbler.com/1.0/user/jnunemaker/events.ics', @user.current_events(:ical))
|
44
|
+
assert_equal('http://ws.audioscrobbler.com/1.0/user/jnunemaker/events.ics', @user.current_events(:ics))
|
45
|
+
assert_equal('http://ws.audioscrobbler.com/1.0/user/jnunemaker/events.rss', @user.current_events(:rss))
|
46
|
+
end
|
47
|
+
|
48
|
+
test 'should know the correct friends events addresses' do
|
49
|
+
assert_equal('http://ws.audioscrobbler.com/1.0/user/jnunemaker/friendevents.ics', @user.friends_events(:ical))
|
50
|
+
assert_equal('http://ws.audioscrobbler.com/1.0/user/jnunemaker/friendevents.ics', @user.friends_events(:ics))
|
51
|
+
assert_equal('http://ws.audioscrobbler.com/1.0/user/jnunemaker/friendevents.rss', @user.friends_events(:rss))
|
52
|
+
end
|
53
|
+
|
54
|
+
test 'should know the correct recommended events addresses' do
|
55
|
+
assert_equal('http://ws.audioscrobbler.com/1.0/user/jnunemaker/eventsysrecs.ics', @user.recommended_events(:ical))
|
56
|
+
assert_equal('http://ws.audioscrobbler.com/1.0/user/jnunemaker/eventsysrecs.ics', @user.recommended_events(:ics))
|
57
|
+
assert_equal('http://ws.audioscrobbler.com/1.0/user/jnunemaker/eventsysrecs.rss', @user.recommended_events(:rss))
|
58
|
+
end
|
59
|
+
|
60
|
+
test 'should be able to include profile during initialization' do
|
61
|
+
user = Scrobbler::User.new('jnunemaker', :include_profile => true)
|
62
|
+
assert_equal('3017870', user.id)
|
63
|
+
assert_equal('4', user.cluster)
|
64
|
+
assert_equal('http://www.last.fm/user/jnunemaker/', user.url)
|
65
|
+
assert_equal('John Nunemaker', user.realname)
|
66
|
+
assert_equal('d5bbe280b7a41d4a87253361692ef105b983cf1a', user.mbox_sha1sum)
|
67
|
+
assert_equal('Dec 8, 2005', user.registered)
|
68
|
+
assert_equal('1134050307', user.registered_unixtime)
|
69
|
+
assert_equal('25', user.age)
|
70
|
+
assert_equal('m', user.gender)
|
71
|
+
assert_equal('United States', user.country)
|
72
|
+
assert_equal('13267', user.playcount)
|
73
|
+
assert_equal('http://panther1.last.fm/avatar/5cb420de0855dadf6bcb1090d8ff02bb.jpg', user.avatar)
|
74
|
+
end
|
75
|
+
|
76
|
+
test 'should be able to load users profile' do
|
77
|
+
@user.load_profile
|
78
|
+
assert_equal('3017870', @user.id)
|
79
|
+
assert_equal('4', @user.cluster)
|
80
|
+
assert_equal('http://www.last.fm/user/jnunemaker/', @user.url)
|
81
|
+
assert_equal('John Nunemaker', @user.realname)
|
82
|
+
assert_equal('d5bbe280b7a41d4a87253361692ef105b983cf1a', @user.mbox_sha1sum)
|
83
|
+
assert_equal('Dec 8, 2005', @user.registered)
|
84
|
+
assert_equal('1134050307', @user.registered_unixtime)
|
85
|
+
assert_equal('25', @user.age)
|
86
|
+
assert_equal('m', @user.gender)
|
87
|
+
assert_equal('United States', @user.country)
|
88
|
+
assert_equal('13267', @user.playcount)
|
89
|
+
assert_equal('http://panther1.last.fm/avatar/5cb420de0855dadf6bcb1090d8ff02bb.jpg', @user.avatar)
|
90
|
+
end
|
91
|
+
|
92
|
+
test "should be able to get a user's top artists" do
|
93
|
+
assert_equal(3, @user.top_artists.size)
|
94
|
+
first = @user.top_artists.first
|
95
|
+
assert_equal('Dixie Chicks', first.name)
|
96
|
+
assert_equal('3248ed2d-bada-41b5-a7b6-ac88faa1f1ac', first.mbid)
|
97
|
+
assert_equal('592', first.playcount)
|
98
|
+
assert_equal('1', first.rank)
|
99
|
+
assert_equal('http://www.last.fm/music/Dixie+Chicks', first.url)
|
100
|
+
assert_equal('http://static3.last.fm/storable/image/182497/small.jpg', first.thumbnail)
|
101
|
+
assert_equal('http://panther1.last.fm/proposedimages/sidebar/6/4037/512759.jpg', first.image)
|
102
|
+
end
|
103
|
+
|
104
|
+
test 'should be able to get top albums' do
|
105
|
+
assert_equal(3, @user.top_albums.size)
|
106
|
+
first = @user.top_albums.first
|
107
|
+
assert_equal('LeAnn Rimes', first.artist)
|
108
|
+
assert_equal('9092d8e1-9b38-4372-a96d-000b8561a8bc', first.artist_mbid)
|
109
|
+
assert_equal('This Woman', first.name)
|
110
|
+
assert_equal('080a4038-5156-460a-8dd5-daaa7d16b6a6', first.mbid)
|
111
|
+
assert_equal('297', first.playcount)
|
112
|
+
assert_equal('1', first.rank)
|
113
|
+
assert_equal('http://www.last.fm/music/LeAnn+Rimes/This+Woman', first.url)
|
114
|
+
assert_equal('http://images.amazon.com/images/P/B00067BD8K.01._SCMZZZZZZZ_.jpg', first.image(:small))
|
115
|
+
assert_equal('http://images.amazon.com/images/P/B00067BD8K.01._SCMZZZZZZZ_.jpg', first.image(:medium))
|
116
|
+
assert_equal('http://images.amazon.com/images/P/B00067BD8K.01._SCMZZZZZZZ_.jpg', first.image(:large))
|
117
|
+
end
|
118
|
+
|
119
|
+
test 'should be able to get top tracks' do
|
120
|
+
assert_equal(3, @user.top_tracks.size)
|
121
|
+
first = @user.top_tracks.first
|
122
|
+
assert_equal("Probably Wouldn't Be This Way", first.name)
|
123
|
+
assert_equal('LeAnn Rimes', first.artist)
|
124
|
+
assert_equal('9092d8e1-9b38-4372-a96d-000b8561a8bc', first.artist_mbid)
|
125
|
+
assert_equal("", first.mbid)
|
126
|
+
assert_equal('61', first.playcount)
|
127
|
+
assert_equal('1', first.rank)
|
128
|
+
assert_equal('http://www.last.fm/music/LeAnn+Rimes/_/Probably+Wouldn%27t+Be+This+Way', first.url)
|
129
|
+
end
|
130
|
+
|
131
|
+
test 'should be able to get top tags' do
|
132
|
+
assert_equal(3, @user.top_tags.size)
|
133
|
+
first = @user.top_tags.first
|
134
|
+
assert_equal("country", first.name)
|
135
|
+
assert_equal("6", first.count)
|
136
|
+
assert_equal("http://www.last.fm/tag/country", first.url)
|
137
|
+
end
|
138
|
+
|
139
|
+
# not implemented
|
140
|
+
test 'should be able to get top tags for artist' do
|
141
|
+
end
|
142
|
+
# not implemented
|
143
|
+
test 'should be able to get top tags for album' do
|
144
|
+
end
|
145
|
+
# not implemented
|
146
|
+
test 'should be able to get top tags for track' do
|
147
|
+
end
|
148
|
+
|
149
|
+
test 'should have friends' do
|
150
|
+
assert_equal(3, @user.friends.size)
|
151
|
+
first = @user.friends.first
|
152
|
+
assert_equal('oaknd1', first.username)
|
153
|
+
assert_equal('http://www.last.fm/user/oaknd1/', first.url)
|
154
|
+
assert_equal('http://panther1.last.fm/avatar/1894043b3e8995c51f7bb5e3210ef97a.jpg', first.avatar)
|
155
|
+
end
|
156
|
+
|
157
|
+
test 'should have neighbours' do
|
158
|
+
assert_equal(3, @user.neighbours.size)
|
159
|
+
first = @user.neighbours.first
|
160
|
+
assert_equal('xBluejeanbabyx', first.username)
|
161
|
+
assert_equal('http://www.last.fm/user/xBluejeanbabyx/', first.url)
|
162
|
+
assert_equal('http://panther1.last.fm/avatar/d4de2144dc9b651b02d5d633124f0205.jpg', first.avatar)
|
163
|
+
end
|
164
|
+
|
165
|
+
test 'should have recent tracks' do
|
166
|
+
assert_equal(3, @user.recent_tracks.size)
|
167
|
+
first = @user.recent_tracks.first
|
168
|
+
assert_equal('Recovering the Satellites', first.name)
|
169
|
+
assert_equal('Counting Crows', first.artist)
|
170
|
+
assert_equal('a0327dc2-dc76-44d5-aec6-47cd2dff1469', first.artist_mbid)
|
171
|
+
assert_equal('', first.mbid)
|
172
|
+
assert_equal('328bc43b-a81a-4dc0-844f-1a27880e5fb2', first.album_mbid)
|
173
|
+
assert_equal('Recovering the Satellites', first.album)
|
174
|
+
assert_equal('http://www.last.fm/music/Counting+Crows/_/Recovering+the+Satellites', first.url)
|
175
|
+
assert_equal(Time.mktime(2007, 5, 4, 21, 1, 00), first.date)
|
176
|
+
assert_equal('1178312462', first.date_uts)
|
177
|
+
end
|
178
|
+
|
179
|
+
test 'should have recent banned tracks' do
|
180
|
+
assert_equal(3, @user.recent_banned_tracks.size)
|
181
|
+
first = @user.recent_banned_tracks.first
|
182
|
+
assert_equal('Dress Rehearsal Rag', first.name)
|
183
|
+
assert_equal('Leonard Cohen', first.artist)
|
184
|
+
assert_equal('65314b12-0e08-43fa-ba33-baaa7b874c15', first.artist_mbid)
|
185
|
+
assert_equal('', first.mbid)
|
186
|
+
assert_equal('http://www.last.fm/music/Leonard+Cohen/_/Dress+Rehearsal+Rag', first.url)
|
187
|
+
assert_equal(Time.mktime(2006, 9, 27, 14, 19, 00), first.date)
|
188
|
+
assert_equal('1159366744', first.date_uts)
|
189
|
+
end
|
190
|
+
|
191
|
+
test 'should have recent loved tracks' do
|
192
|
+
assert_equal(3, @user.recent_loved_tracks.size)
|
193
|
+
first = @user.recent_loved_tracks.first
|
194
|
+
assert_equal('Am I Missing', first.name)
|
195
|
+
assert_equal('Dashboard Confessional', first.artist)
|
196
|
+
assert_equal('50549203-9602-451c-b49f-ff031ba8635c', first.artist_mbid)
|
197
|
+
assert_equal('', first.mbid)
|
198
|
+
assert_equal('http://www.last.fm/music/Dashboard+Confessional/_/Am+I+Missing', first.url)
|
199
|
+
assert_equal(Time.mktime(2006, 9, 26, 17, 43, 00), first.date)
|
200
|
+
assert_equal('1159292606', first.date_uts)
|
201
|
+
end
|
202
|
+
|
203
|
+
test 'should have recommendations' do
|
204
|
+
assert_equal(3, @user.recommendations.size)
|
205
|
+
first = @user.recommendations.first
|
206
|
+
assert_equal('Kaiser Chiefs', first.name)
|
207
|
+
assert_equal('90218af4-4d58-4821-8d41-2ee295ebbe21', first.mbid)
|
208
|
+
assert_equal('http://www.last.fm/music/Kaiser+Chiefs', first.url)
|
209
|
+
end
|
210
|
+
|
211
|
+
test 'should have charts' do
|
212
|
+
assert_equal(71, @user.charts.size)
|
213
|
+
first = @user.charts.first
|
214
|
+
assert_equal(1134302403, first.from)
|
215
|
+
assert_equal(1134907203, first.to)
|
216
|
+
end
|
217
|
+
|
218
|
+
test 'should have weekly artist chart' do
|
219
|
+
chart = @user.weekly_artist_chart
|
220
|
+
assert_equal(5, chart.size)
|
221
|
+
first = chart.first
|
222
|
+
assert_equal('Rascal Flatts', first.name)
|
223
|
+
assert_equal('6e0ae159-8449-4262-bba5-18ec87fa529f', first.mbid)
|
224
|
+
assert_equal('1', first.chartposition)
|
225
|
+
assert_equal('25', first.playcount)
|
226
|
+
assert_equal('http://www.last.fm/music/Rascal+Flatts', first.url)
|
227
|
+
end
|
228
|
+
|
229
|
+
test 'should have weekly artist chart for past weeks' do
|
230
|
+
chart = @user.weekly_artist_chart(1138536002, 1139140802)
|
231
|
+
assert_equal(8, chart.size)
|
232
|
+
first = chart.first
|
233
|
+
assert_equal('Jenny Lewis with The Watson Twins', first.name)
|
234
|
+
assert_equal('4b179fe2-dfa5-40b1-b6db-b56dbc3b5f09', first.mbid)
|
235
|
+
assert_equal('1', first.chartposition)
|
236
|
+
assert_equal('48', first.playcount)
|
237
|
+
assert_equal('http://www.last.fm/music/Jenny+Lewis+with+The+Watson+Twins', first.url)
|
238
|
+
end
|
239
|
+
|
240
|
+
test 'should have weekly album chart' do
|
241
|
+
chart = @user.weekly_album_chart
|
242
|
+
assert_equal(4, chart.size)
|
243
|
+
first = chart.first
|
244
|
+
assert_equal('Reba McEntire', first.artist)
|
245
|
+
assert_equal('3ec17e85-9284-4f4c-8831-4e56c2354cdb', first.artist_mbid)
|
246
|
+
assert_equal("Reba #1's", first.name)
|
247
|
+
assert_equal('', first.mbid)
|
248
|
+
assert_equal('1', first.chartposition)
|
249
|
+
assert_equal('13', first.playcount)
|
250
|
+
assert_equal('http://www.last.fm/music/Reba+McEntire/Reba%2B%25231%2527s', first.url)
|
251
|
+
end
|
252
|
+
|
253
|
+
test 'should have weekly album chart for past weeks' do
|
254
|
+
chart = @user.weekly_album_chart(1138536002, 1139140802)
|
255
|
+
assert_equal(4, chart.size)
|
256
|
+
first = chart.first
|
257
|
+
assert_equal('Jewel', first.artist)
|
258
|
+
assert_equal('abae8575-ec8a-4736-abc3-1ad5093a68aa', first.artist_mbid)
|
259
|
+
assert_equal("0304", first.name)
|
260
|
+
assert_equal('52b3f067-9d82-488c-9747-6d608d9b9486', first.mbid)
|
261
|
+
assert_equal('1', first.chartposition)
|
262
|
+
assert_equal('13', first.playcount)
|
263
|
+
assert_equal('http://www.last.fm/music/Jewel/0304', first.url)
|
264
|
+
end
|
265
|
+
|
266
|
+
test 'should have track album chart' do
|
267
|
+
chart = @user.weekly_track_chart
|
268
|
+
assert_equal(4, chart.size)
|
269
|
+
first = chart.first
|
270
|
+
assert_equal('Rebecca St. James', first.artist)
|
271
|
+
assert_equal('302716e4-a702-4bbc-baac-591f8a8e20bc', first.artist_mbid)
|
272
|
+
assert_equal('Omega', first.name)
|
273
|
+
assert_equal('', first.mbid)
|
274
|
+
assert_equal('1', first.chartposition)
|
275
|
+
assert_equal('2', first.playcount)
|
276
|
+
assert_equal('http://www.last.fm/music/Rebecca+St.+James/_/Omega', first.url)
|
277
|
+
end
|
278
|
+
|
279
|
+
test 'should have weekly track chart for past weeks' do
|
280
|
+
chart = @user.weekly_track_chart(1138536002, 1139140802)
|
281
|
+
assert_equal(4, chart.size)
|
282
|
+
first = chart.first
|
283
|
+
assert_equal('Natasha Bedingfield', first.artist)
|
284
|
+
assert_equal('8b477559-946e-4ef2-9fe1-446cff8fdd79', first.artist_mbid)
|
285
|
+
assert_equal('Unwritten', first.name)
|
286
|
+
assert_equal('', first.mbid)
|
287
|
+
assert_equal('1', first.chartposition)
|
288
|
+
assert_equal('8', first.playcount)
|
289
|
+
assert_equal('http://www.last.fm/music/Natasha+Bedingfield/_/Unwritten', first.url)
|
290
|
+
end
|
291
|
+
end
|