scrobbler 0.1.0
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.
- data/History.txt +1 -0
- data/Manifest.txt +58 -0
- data/README.txt +71 -0
- data/Rakefile +89 -0
- data/examples/album.rb +18 -0
- data/examples/artist.rb +14 -0
- data/examples/tag.rb +12 -0
- data/examples/track.rb +7 -0
- data/examples/user.rb +15 -0
- data/lib/scrobbler.rb +13 -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/rest.rb +47 -0
- data/lib/scrobbler/tag.rb +104 -0
- data/lib/scrobbler/track.rb +96 -0
- data/lib/scrobbler/user.rb +192 -0
- data/lib/scrobbler/version.rb +9 -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 +26 -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/tag_test.rb +65 -0
- data/test/unit/track_test.rb +42 -0
- data/test/unit/user_test.rb +291 -0
- metadata +120 -0
@@ -0,0 +1,38 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<weeklyartistchart user="jnunemaker" from="1177848000" to="1178452800">
|
3
|
+
<artist>
|
4
|
+
<name>Rascal Flatts</name>
|
5
|
+
<mbid>6e0ae159-8449-4262-bba5-18ec87fa529f</mbid>
|
6
|
+
<chartposition>1</chartposition>
|
7
|
+
<playcount>25</playcount>
|
8
|
+
<url>http://www.last.fm/music/Rascal+Flatts</url>
|
9
|
+
</artist>
|
10
|
+
<artist>
|
11
|
+
<name>Reba McEntire</name>
|
12
|
+
<mbid>3ec17e85-9284-4f4c-8831-4e56c2354cdb</mbid>
|
13
|
+
<chartposition>2</chartposition>
|
14
|
+
<playcount>15</playcount>
|
15
|
+
<url>http://www.last.fm/music/Reba+McEntire</url>
|
16
|
+
</artist>
|
17
|
+
<artist>
|
18
|
+
<name>LeAnn Rimes</name>
|
19
|
+
<mbid>9092d8e1-9b38-4372-a96d-000b8561a8bc</mbid>
|
20
|
+
<chartposition>3</chartposition>
|
21
|
+
<playcount>14</playcount>
|
22
|
+
<url>http://www.last.fm/music/LeAnn+Rimes</url>
|
23
|
+
</artist>
|
24
|
+
<artist>
|
25
|
+
<name>SHeDaisy</name>
|
26
|
+
<mbid>166c939c-a97e-44b9-b405-23d49a72df4e</mbid>
|
27
|
+
<chartposition>4</chartposition>
|
28
|
+
<playcount>13</playcount>
|
29
|
+
<url>http://www.last.fm/music/SHeDaisy</url>
|
30
|
+
</artist>
|
31
|
+
<artist>
|
32
|
+
<name>Sawyer Brown</name>
|
33
|
+
<mbid>1b69a7bc-7563-4aaf-a859-8b6050a7a0f2</mbid>
|
34
|
+
<chartposition>5</chartposition>
|
35
|
+
<playcount>12</playcount>
|
36
|
+
<url>http://www.last.fm/music/Sawyer+Brown</url>
|
37
|
+
</artist>
|
38
|
+
</weeklyartistchart>
|
@@ -0,0 +1,59 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<weeklyartistchart user="jnunemaker" from="1138536002" to="1139140802">
|
3
|
+
<artist>
|
4
|
+
<name>Jenny Lewis with The Watson Twins</name>
|
5
|
+
<mbid>4b179fe2-dfa5-40b1-b6db-b56dbc3b5f09</mbid>
|
6
|
+
<chartposition>1</chartposition>
|
7
|
+
<playcount>48</playcount>
|
8
|
+
<url>http://www.last.fm/music/Jenny+Lewis+with+The+Watson+Twins</url>
|
9
|
+
</artist>
|
10
|
+
<artist>
|
11
|
+
<name>Johnny Cash</name>
|
12
|
+
<mbid>d43d12a1-2dc9-4257-a2fd-0a3bb1081b86</mbid>
|
13
|
+
<chartposition>2</chartposition>
|
14
|
+
<playcount>25</playcount>
|
15
|
+
<url>http://www.last.fm/music/Johnny+Cash</url>
|
16
|
+
</artist>
|
17
|
+
<artist>
|
18
|
+
<name>Jewel</name>
|
19
|
+
<mbid>abae8575-ec8a-4736-abc3-1ad5093a68aa</mbid>
|
20
|
+
<chartposition>3</chartposition>
|
21
|
+
<playcount>14</playcount>
|
22
|
+
<url>http://www.last.fm/music/Jewel</url>
|
23
|
+
</artist>
|
24
|
+
<artist>
|
25
|
+
<name>Nine Inch Nails</name>
|
26
|
+
<mbid>b7ffd2af-418f-4be2-bdd1-22f8b48613da</mbid>
|
27
|
+
<chartposition>4</chartposition>
|
28
|
+
<playcount>8</playcount>
|
29
|
+
<url>http://www.last.fm/music/Nine+Inch+Nails</url>
|
30
|
+
</artist>
|
31
|
+
<artist>
|
32
|
+
<name>Natasha Bedingfield</name>
|
33
|
+
<mbid>8b477559-946e-4ef2-9fe1-446cff8fdd79</mbid>
|
34
|
+
<chartposition>4</chartposition>
|
35
|
+
<playcount>8</playcount>
|
36
|
+
<url>http://www.last.fm/music/Natasha+Bedingfield</url>
|
37
|
+
</artist>
|
38
|
+
<artist>
|
39
|
+
<name>Martina McBride</name>
|
40
|
+
<mbid>b0a55bd8-60c7-45c1-b78e-f20e4c8adba1</mbid>
|
41
|
+
<chartposition>6</chartposition>
|
42
|
+
<playcount>7</playcount>
|
43
|
+
<url>http://www.last.fm/music/Martina+McBride</url>
|
44
|
+
</artist>
|
45
|
+
<artist>
|
46
|
+
<name>Kanye West</name>
|
47
|
+
<mbid>164f0d73-1234-4e2c-8743-d77bf2191051</mbid>
|
48
|
+
<chartposition>7</chartposition>
|
49
|
+
<playcount>6</playcount>
|
50
|
+
<url>http://www.last.fm/music/Kanye+West</url>
|
51
|
+
</artist>
|
52
|
+
<artist>
|
53
|
+
<name>The Pussycat Dolls</name>
|
54
|
+
<mbid>1fda852b-92e9-4562-82fa-c52820a77b23</mbid>
|
55
|
+
<chartposition>8</chartposition>
|
56
|
+
<playcount>5</playcount>
|
57
|
+
<url>http://www.last.fm/music/The+Pussycat+Dolls</url>
|
58
|
+
</artist>
|
59
|
+
</weeklyartistchart>
|
@@ -0,0 +1,74 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<weeklychartlist user="jnunemaker">
|
3
|
+
<chart from="1134302403" to="1134907203"/>
|
4
|
+
<chart from="1134907202" to="1135512002"/>
|
5
|
+
<chart from="1135512002" to="1136116802"/>
|
6
|
+
<chart from="1136116801" to="1136721601"/>
|
7
|
+
<chart from="1136721601" to="1137326401"/>
|
8
|
+
<chart from="1137326402" to="1137931202"/>
|
9
|
+
<chart from="1137931202" to="1138536002"/>
|
10
|
+
<chart from="1138536002" to="1139140802"/>
|
11
|
+
<chart from="1139140801" to="1139745601"/>
|
12
|
+
<chart from="1139745601" to="1140350401"/>
|
13
|
+
<chart from="1140350401" to="1140955201"/>
|
14
|
+
<chart from="1140955203" to="1141560003"/>
|
15
|
+
<chart from="1141560002" to="1142164802"/>
|
16
|
+
<chart from="1142164802" to="1142769602"/>
|
17
|
+
<chart from="1142769602" to="1143374402"/>
|
18
|
+
<chart from="1143374402" to="1143979202"/>
|
19
|
+
<chart from="1143979202" to="1144584000"/>
|
20
|
+
<chart from="1144584000" to="1145188800"/>
|
21
|
+
<chart from="1145188800" to="1145793600"/>
|
22
|
+
<chart from="1145793600" to="1146398400"/>
|
23
|
+
<chart from="1146398400" to="1147003200"/>
|
24
|
+
<chart from="1147003200" to="1147608000"/>
|
25
|
+
<chart from="1147608000" to="1148212800"/>
|
26
|
+
<chart from="1148212800" to="1148817600"/>
|
27
|
+
<chart from="1148817600" to="1149422400"/>
|
28
|
+
<chart from="1149422400" to="1150027200"/>
|
29
|
+
<chart from="1150027200" to="1150632000"/>
|
30
|
+
<chart from="1150632000" to="1151236800"/>
|
31
|
+
<chart from="1151236800" to="1151841600"/>
|
32
|
+
<chart from="1151841600" to="1152446400"/>
|
33
|
+
<chart from="1152446400" to="1153051200"/>
|
34
|
+
<chart from="1153656000" to="1154260800"/>
|
35
|
+
<chart from="1154260800" to="1154865600"/>
|
36
|
+
<chart from="1154865600" to="1155470400"/>
|
37
|
+
<chart from="1155470400" to="1156075200"/>
|
38
|
+
<chart from="1156075200" to="1156680000"/>
|
39
|
+
<chart from="1156680000" to="1157284800"/>
|
40
|
+
<chart from="1157284800" to="1157889600"/>
|
41
|
+
<chart from="1157889600" to="1158494400"/>
|
42
|
+
<chart from="1158494400" to="1159099200"/>
|
43
|
+
<chart from="1159099200" to="1159704000"/>
|
44
|
+
<chart from="1159704000" to="1160308800"/>
|
45
|
+
<chart from="1160308800" to="1160913600"/>
|
46
|
+
<chart from="1160913600" to="1161518400"/>
|
47
|
+
<chart from="1162123200" to="1162728000"/>
|
48
|
+
<chart from="1162728000" to="1163332800"/>
|
49
|
+
<chart from="1163332800" to="1163937600"/>
|
50
|
+
<chart from="1163937600" to="1164542400"/>
|
51
|
+
<chart from="1164542400" to="1165147200"/>
|
52
|
+
<chart from="1165147200" to="1165752000"/>
|
53
|
+
<chart from="1165752000" to="1166356800"/>
|
54
|
+
<chart from="1166356800" to="1166961600"/>
|
55
|
+
<chart from="1166961600" to="1167566400"/>
|
56
|
+
<chart from="1167566400" to="1168171200"/>
|
57
|
+
<chart from="1168171200" to="1168776000"/>
|
58
|
+
<chart from="1168776000" to="1169380800"/>
|
59
|
+
<chart from="1169380800" to="1169985600"/>
|
60
|
+
<chart from="1169985600" to="1170590400"/>
|
61
|
+
<chart from="1170590400" to="1171195200"/>
|
62
|
+
<chart from="1171195200" to="1171800000"/>
|
63
|
+
<chart from="1171800000" to="1172404800"/>
|
64
|
+
<chart from="1172404800" to="1173009600"/>
|
65
|
+
<chart from="1173009600" to="1173614400"/>
|
66
|
+
<chart from="1173614400" to="1174219200"/>
|
67
|
+
<chart from="1174219200" to="1174824000"/>
|
68
|
+
<chart from="1174824000" to="1175428800"/>
|
69
|
+
<chart from="1175428800" to="1176033600"/>
|
70
|
+
<chart from="1176033600" to="1176638400"/>
|
71
|
+
<chart from="1176638400" to="1177243200"/>
|
72
|
+
<chart from="1177243200" to="1177848000"/>
|
73
|
+
<chart from="1177848000" to="1178452800"/>
|
74
|
+
</weeklychartlist>
|
@@ -0,0 +1,35 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<weeklytrackchart user="jnunemaker" from="1177848000" to="1178452800">
|
3
|
+
<track>
|
4
|
+
<artist mbid="302716e4-a702-4bbc-baac-591f8a8e20bc">Rebecca St. James</artist>
|
5
|
+
<name>Omega</name>
|
6
|
+
<mbid></mbid>
|
7
|
+
<chartposition>1</chartposition>
|
8
|
+
<playcount>2</playcount>
|
9
|
+
<url>http://www.last.fm/music/Rebecca+St.+James/_/Omega</url>
|
10
|
+
</track>
|
11
|
+
<track>
|
12
|
+
<artist mbid="0cd4810e-9f57-4003-bdfa-e188cd3ba818">Michael English</artist>
|
13
|
+
<name>In Christ Alone</name>
|
14
|
+
<mbid></mbid>
|
15
|
+
<chartposition>2</chartposition>
|
16
|
+
<playcount>1</playcount>
|
17
|
+
<url>http://www.last.fm/music/Michael+English/_/In+Christ+Alone</url>
|
18
|
+
</track>
|
19
|
+
<track>
|
20
|
+
<artist mbid="3ec17e85-9284-4f4c-8831-4e56c2354cdb">Reba McEntire</artist>
|
21
|
+
<name>How Was I to Know</name>
|
22
|
+
<mbid></mbid>
|
23
|
+
<chartposition>2</chartposition>
|
24
|
+
<playcount>1</playcount>
|
25
|
+
<url>http://www.last.fm/music/Reba+McEntire/_/How+Was+I+to+Know</url>
|
26
|
+
</track>
|
27
|
+
<track>
|
28
|
+
<artist mbid="faabb55d-3c9e-4c23-8779-732ac2ee2c0d">Shania Twain</artist>
|
29
|
+
<name>Don't Be Stupid (You Know I Love You) (remix)</name>
|
30
|
+
<mbid></mbid>
|
31
|
+
<chartposition>2</chartposition>
|
32
|
+
<playcount>1</playcount>
|
33
|
+
<url>http://www.last.fm/music/Shania+Twain/_/Don%27t+Be+Stupid+%28You+Know+I+Love+You%29+%28remix%29</url>
|
34
|
+
</track>
|
35
|
+
</weeklytrackchart>
|
@@ -0,0 +1,35 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<weeklytrackchart user="jnunemaker" from="1138536002" to="1139140802">
|
3
|
+
<track>
|
4
|
+
<artist mbid="8b477559-946e-4ef2-9fe1-446cff8fdd79">Natasha Bedingfield</artist>
|
5
|
+
<name>Unwritten</name>
|
6
|
+
<mbid></mbid>
|
7
|
+
<chartposition>1</chartposition>
|
8
|
+
<playcount>8</playcount>
|
9
|
+
<url>http://www.last.fm/music/Natasha+Bedingfield/_/Unwritten</url>
|
10
|
+
</track>
|
11
|
+
<track>
|
12
|
+
<artist mbid="d43d12a1-2dc9-4257-a2fd-0a3bb1081b86">Johnny Cash</artist>
|
13
|
+
<name>Hurt</name>
|
14
|
+
<mbid></mbid>
|
15
|
+
<chartposition>2</chartposition>
|
16
|
+
<playcount>6</playcount>
|
17
|
+
<url>http://www.last.fm/music/Johnny+Cash/_/Hurt</url>
|
18
|
+
</track>
|
19
|
+
<track>
|
20
|
+
<artist mbid="ba853904-ae25-4ebb-89d6-c44cfbd71bd2">Blur</artist>
|
21
|
+
<name>Song 2</name>
|
22
|
+
<mbid></mbid>
|
23
|
+
<chartposition>3</chartposition>
|
24
|
+
<playcount>4</playcount>
|
25
|
+
<url>http://www.last.fm/music/Blur/_/Song+2</url>
|
26
|
+
</track>
|
27
|
+
<track>
|
28
|
+
<artist mbid="bc710bcf-8815-42cf-bad2-3f1d12246aeb">Nickelback</artist>
|
29
|
+
<name>Photograph</name>
|
30
|
+
<mbid></mbid>
|
31
|
+
<chartposition>3</chartposition>
|
32
|
+
<playcount>4</playcount>
|
33
|
+
<url>http://www.last.fm/music/Nickelback/_/Photograph</url>
|
34
|
+
</track>
|
35
|
+
</weeklytrackchart>
|
data/test/mocks/rest.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../lib/scrobbler/rest'
|
2
|
+
|
3
|
+
module Scrobbler
|
4
|
+
module REST
|
5
|
+
class Connection
|
6
|
+
# reads xml fixture file instead of hitting up the internets
|
7
|
+
def request(resource, method = "get", args = nil)
|
8
|
+
pieces = resource.split('/')
|
9
|
+
pieces.shift
|
10
|
+
pieces.shift
|
11
|
+
folder = pieces.shift
|
12
|
+
file = pieces.last[0, pieces.last.index('.xml')]
|
13
|
+
base_pieces = pieces.last.split('?')
|
14
|
+
|
15
|
+
file = if base_pieces.size > 1
|
16
|
+
# if query string params are in resource they are underscore separated for filenames
|
17
|
+
base_pieces.last.split('&').inject("#{file}_") { |str, pair| str << pair.split('=').join('_') + '_'; str }.chop!
|
18
|
+
else
|
19
|
+
file
|
20
|
+
end
|
21
|
+
|
22
|
+
File.read(File.dirname(__FILE__) + "/../fixtures/xml/#{folder}/#{file}.xml")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require File.dirname(__FILE__) + '/../lib/scrobbler'
|
3
|
+
require File.dirname(__FILE__) + '/mocks/rest'
|
4
|
+
|
5
|
+
class << Test::Unit::TestCase
|
6
|
+
def test(name, &block)
|
7
|
+
test_name = :"test_#{name.gsub(' ','_')}"
|
8
|
+
raise ArgumentError, "#{test_name} is already defined" if self.instance_methods.include? test_name.to_s
|
9
|
+
define_method test_name, &block
|
10
|
+
end
|
11
|
+
|
12
|
+
def expect(expected_value, &block)
|
13
|
+
define_method :"test_#{caller.first.split("/").last}" do
|
14
|
+
assert_equal expected_value, instance_eval(&block)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper.rb'
|
2
|
+
|
3
|
+
class TestAlbum < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@album = Scrobbler::Album.new('Carrie Underwood', 'Some Hearts')
|
7
|
+
end
|
8
|
+
|
9
|
+
test 'should require the artist name' do
|
10
|
+
assert_raises(ArgumentError) { Scrobbler::Album.new('', 'Some Hearts') }
|
11
|
+
end
|
12
|
+
|
13
|
+
test 'should require the track name' do
|
14
|
+
assert_raises(ArgumentError) { Scrobbler::Album.new('Carrie Underwood', '') }
|
15
|
+
end
|
16
|
+
|
17
|
+
test 'should know the artist' do
|
18
|
+
assert_equal('Carrie Underwood', @album.artist)
|
19
|
+
end
|
20
|
+
|
21
|
+
test "should know it's name" do
|
22
|
+
assert_equal('Some Hearts', @album.name)
|
23
|
+
end
|
24
|
+
|
25
|
+
test 'should have correct api path' do
|
26
|
+
assert_equal("/1.0/album/Carrie+Underwood/Some+Hearts", @album.api_path)
|
27
|
+
end
|
28
|
+
|
29
|
+
test 'should be able to load album info' do
|
30
|
+
@album.load_info
|
31
|
+
assert_equal('18589', @album.reach)
|
32
|
+
assert_equal('http://www.last.fm/music/Carrie+Underwood/Some+Hearts', @album.url)
|
33
|
+
assert_equal(Time.mktime(2005, 11, 15, 00, 00, 00), @album.release_date)
|
34
|
+
assert_equal(14, @album.tracks.size)
|
35
|
+
assert_equal('Wasted', @album.tracks.first.name)
|
36
|
+
assert_equal('http://www.last.fm/music/Carrie+Underwood/_/Wasted', @album.tracks.first.url)
|
37
|
+
assert_equal('6738', @album.tracks.first.reach)
|
38
|
+
end
|
39
|
+
|
40
|
+
test 'should be able to find an ablum' do
|
41
|
+
album = Scrobbler::Album.find('Carrie Underwood', 'Some Hearts')
|
42
|
+
assert_equal('Carrie Underwood', album.artist)
|
43
|
+
assert_equal('Some Hearts', album.name)
|
44
|
+
end
|
45
|
+
|
46
|
+
test "should be able to find an ablum and load the album's info" do
|
47
|
+
album = Scrobbler::Album.find('Carrie Underwood', 'Some Hearts', :include_info => true)
|
48
|
+
assert_equal('Carrie Underwood', album.artist)
|
49
|
+
assert_equal('Some Hearts', album.name)
|
50
|
+
assert_equal('18589', album.reach)
|
51
|
+
assert_equal('http://www.last.fm/music/Carrie+Underwood/Some+Hearts', album.url)
|
52
|
+
assert_equal(Time.mktime(2005, 11, 15, 00, 00, 00), album.release_date)
|
53
|
+
end
|
54
|
+
|
55
|
+
test "should be able to include the album's info on initialize" do
|
56
|
+
album = Scrobbler::Album.new('Carrie Underwood', 'Some Hearts', :include_info => true)
|
57
|
+
assert_equal('Carrie Underwood', album.artist)
|
58
|
+
assert_equal('Some Hearts', album.name)
|
59
|
+
assert_equal('18589', album.reach)
|
60
|
+
assert_equal('http://www.last.fm/music/Carrie+Underwood/Some+Hearts', album.url)
|
61
|
+
assert_equal(Time.mktime(2005, 11, 15, 00, 00, 00), album.release_date)
|
62
|
+
end
|
63
|
+
|
64
|
+
test 'should load info when trying to access tracks if info has not been loaded' do
|
65
|
+
assert_equal(14, @album.tracks.size)
|
66
|
+
assert_equal('Wasted', @album.tracks.first.name)
|
67
|
+
assert_equal('http://www.last.fm/music/Carrie+Underwood/_/Wasted', @album.tracks.first.url)
|
68
|
+
assert_equal('6738', @album.tracks.first.reach)
|
69
|
+
end
|
70
|
+
|
71
|
+
test 'should have an image method that accepts a type' do
|
72
|
+
@album.load_info
|
73
|
+
assert_equal('http://images.amazon.com/images/P/B000BGR18W.01.MZZZZZZZ.jpg', @album.image(:small))
|
74
|
+
assert_equal('http://images.amazon.com/images/P/B000BGR18W.01.MZZZZZZZ.jpg', @album.image(:medium))
|
75
|
+
assert_equal('http://images.amazon.com/images/P/B000BGR18W.01.MZZZZZZZ.jpg', @album.image(:large))
|
76
|
+
end
|
77
|
+
|
78
|
+
test "should raise an argument error when attempting to get an image that doesn't exist" do
|
79
|
+
@album.load_info
|
80
|
+
assert_raises(ArgumentError) { @album.image(:fake) }
|
81
|
+
end
|
82
|
+
|
83
|
+
test 'should load info when trying to access an image if the info has not been loaded' do
|
84
|
+
assert_equal('http://images.amazon.com/images/P/B000BGR18W.01.MZZZZZZZ.jpg', @album.image(:small))
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper.rb'
|
2
|
+
|
3
|
+
class TestArtist < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@artist = Scrobbler::Artist.new('Metallica')
|
7
|
+
end
|
8
|
+
|
9
|
+
test 'should require name' do
|
10
|
+
assert_raises(ArgumentError) { Scrobbler::Artist.new('') }
|
11
|
+
end
|
12
|
+
|
13
|
+
test "should know it's name" do
|
14
|
+
assert_equal('Metallica', @artist.name)
|
15
|
+
end
|
16
|
+
|
17
|
+
test 'should have the correct api_path' do
|
18
|
+
assert_equal('/1.0/artist/Metallica', @artist.api_path)
|
19
|
+
end
|
20
|
+
|
21
|
+
test 'should escape api path' do
|
22
|
+
assert_equal('/1.0/artist/Carrie+Underwood', Scrobbler::Artist.new('Carrie Underwood').api_path)
|
23
|
+
end
|
24
|
+
|
25
|
+
test 'should have the correct ical path to current events' do
|
26
|
+
assert_equal('http://ws.audioscrobbler.com/1.0/artist/Metallica/events.ics', @artist.current_events(:ical))
|
27
|
+
end
|
28
|
+
|
29
|
+
test 'should have the correct rss path to current events' do
|
30
|
+
assert_equal('http://ws.audioscrobbler.com/1.0/artist/Metallica/events.rss', @artist.current_events(:rss))
|
31
|
+
end
|
32
|
+
|
33
|
+
test 'should be able to find similar artists' do
|
34
|
+
assert_equal(['Iron Maiden', 'System of a Down', "Guns N' Roses", 'Rammstein'], @artist.similar.collect(&:name))
|
35
|
+
first = @artist.similar.first
|
36
|
+
assert_equal('Iron Maiden', first.name)
|
37
|
+
assert_equal('ca891d65-d9b0-4258-89f7-e6ba29d83767', first.mbid)
|
38
|
+
assert_equal('100', first.match)
|
39
|
+
assert_equal('http://www.last.fm/music/Iron+Maiden', first.url)
|
40
|
+
assert_equal('http://static3.last.fm/storable/image/177412/small.jpg', first.thumbnail)
|
41
|
+
assert_equal('http://panther1.last.fm/proposedimages/sidebar/6/1000107/528560.jpg', first.image)
|
42
|
+
assert_equal('yes', first.streamable)
|
43
|
+
end
|
44
|
+
|
45
|
+
test 'should be able to find top fans' do
|
46
|
+
assert_equal(%w{Kikoin Chrisis92 delekt0r}, @artist.top_fans.collect(&:username))
|
47
|
+
first = @artist.top_fans.first
|
48
|
+
assert_equal('Kikoin', first.username)
|
49
|
+
assert_equal('http://www.last.fm/user/Kikoin/', first.url)
|
50
|
+
assert_equal('http://panther1.last.fm/avatar/621340085aed19b9ab77a0f8c575758a.gif', first.avatar)
|
51
|
+
assert_equal('6081000', first.weight)
|
52
|
+
end
|
53
|
+
|
54
|
+
test 'should be able to find top tracks' do
|
55
|
+
assert_equal(['Nothing Else Matters', 'Enter Sandman', 'Master of Puppets', 'One'], @artist.top_tracks.collect(&:name))
|
56
|
+
first = @artist.top_tracks.first
|
57
|
+
assert_equal('Nothing Else Matters', first.name)
|
58
|
+
assert_equal('', first.mbid)
|
59
|
+
assert_equal('http://www.last.fm/music/Metallica/_/Nothing+Else+Matters', first.url)
|
60
|
+
assert_equal('59135', first.reach)
|
61
|
+
end
|
62
|
+
|
63
|
+
test 'should be able to find top albums' do
|
64
|
+
assert_equal(['Master of Puppets', 'Metallica', 'Reload'], @artist.top_albums.collect(&:name))
|
65
|
+
first = @artist.top_albums.first
|
66
|
+
assert_equal('Master of Puppets', first.name)
|
67
|
+
assert_equal('fed37cfc-2a6d-4569-9ac0-501a7c7598eb', first.mbid)
|
68
|
+
assert_equal('65717', first.reach)
|
69
|
+
assert_equal('http://www.last.fm/music/Metallica/Master+of+Puppets', first.url)
|
70
|
+
assert_equal('http://cdn.last.fm/coverart/50x50/1411810.jpg', first.image(:small))
|
71
|
+
assert_equal('http://cdn.last.fm/coverart/130x130/1411810.jpg', first.image(:medium))
|
72
|
+
assert_equal('http://panther1.last.fm/coverart/130x130/1411810.jpg', first.image(:large))
|
73
|
+
end
|
74
|
+
|
75
|
+
test 'should be able to find top tags' do
|
76
|
+
assert_equal(['metal', 'thrash metal', 'heavy metal'], @artist.top_tags.collect(&:name))
|
77
|
+
first = @artist.top_tags.first
|
78
|
+
assert_equal('metal', first.name)
|
79
|
+
assert_equal('100', first.count)
|
80
|
+
assert_equal('http://www.last.fm/tag/metal', first.url)
|
81
|
+
end
|
82
|
+
end
|