glutton_lastfm 0.1.1 → 0.1.3
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/README.rdoc +7 -0
- data/VERSION +1 -1
- data/glutton_lastfm.gemspec +13 -2
- data/lib/glutton_lastfm.rb +29 -7
- data/test/fixtures/artist_multi_tags_top_tags.xml +403 -0
- data/test/fixtures/artist_no_albums_top_albums.xml +4 -0
- data/test/fixtures/artist_no_events.xml +3 -0
- data/test/fixtures/artist_no_tags_top_tags.xml +3 -0
- data/test/fixtures/known_album_album_search.xml +53 -0
- data/test/fixtures/known_artist_artist_search.xml +339 -0
- data/test/fixtures/multi_album_top_albums.xml +704 -0
- data/test/fixtures/one_album_top_albums.xml +18 -0
- data/test/fixtures/unknown_album_album_search.xml +9 -0
- data/test/fixtures/unknown_artist_artist_search.xml +9 -0
- data/test/fixtures/unknown_artist_top_albums.xml +2 -0
- data/test/test_glutton_lastfm.rb +67 -6
- metadata +14 -3
@@ -0,0 +1,18 @@
|
|
1
|
+
<lfm status="ok">
|
2
|
+
<topalbums artist="Foxboro Hot Tubs" >
|
3
|
+
|
4
|
+
<album rank="1">
|
5
|
+
<name>Coolest Songs In The World! Vol. 7</name>
|
6
|
+
<playcount>1196</playcount>
|
7
|
+
<mbid></mbid>
|
8
|
+
<url>http://www.last.fm/music/Various+Artists/Coolest+Songs+In+The+World%21+Vol.+7</url>
|
9
|
+
<artist>
|
10
|
+
<name>Various Artists</name>
|
11
|
+
<mbid>89ad4ac3-39f7-470e-963a-56509c546377</mbid>
|
12
|
+
<url>http://www.last.fm/music/Various+Artists</url>
|
13
|
+
</artist>
|
14
|
+
<image size="small">http://userserve-ak.last.fm/serve/34s/31438871.jpg</image>
|
15
|
+
<image size="medium">http://userserve-ak.last.fm/serve/64s/31438871.jpg</image>
|
16
|
+
<image size="large">http://userserve-ak.last.fm/serve/126/31438871.jpg</image>
|
17
|
+
<image size="extralarge">http://userserve-ak.last.fm/serve/300x300/31438871.jpg</image>
|
18
|
+
</album></topalbums></lfm>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<lfm status="ok">
|
2
|
+
<results for="nowaytherebeanalbumnamedthis" xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">
|
3
|
+
<opensearch:Query role="request" searchTerms="nowaytherebeanalbumnamedthis" startPage="1" />
|
4
|
+
<opensearch:totalResults>0</opensearch:totalResults>
|
5
|
+
<opensearch:startIndex>0</opensearch:startIndex>
|
6
|
+
<opensearch:itemsPerPage>30</opensearch:itemsPerPage>
|
7
|
+
<albummatches>
|
8
|
+
</albummatches>
|
9
|
+
</results></lfm>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<lfm status="ok">
|
2
|
+
<results for="nowaytherebeanartistnamedthis" xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">
|
3
|
+
<opensearch:Query role="request" searchTerms="nowaytherebeanartistnamedthis" startPage="1" />
|
4
|
+
<opensearch:totalResults>0</opensearch:totalResults>
|
5
|
+
<opensearch:startIndex>0</opensearch:startIndex>
|
6
|
+
<opensearch:itemsPerPage>30</opensearch:itemsPerPage>
|
7
|
+
<artistmatches>
|
8
|
+
</artistmatches>
|
9
|
+
</results></lfm>
|
data/test/test_glutton_lastfm.rb
CHANGED
@@ -1,19 +1,15 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
|
-
# I'm currently only testing two methods and one exception.
|
4
3
|
# HTTP calls are replaced by fixture file responses using the fakeweb gem.
|
4
|
+
# Because of this the API_KEY can be left blank.
|
5
5
|
|
6
6
|
class TestGluttonLastfm < Test::Unit::TestCase
|
7
|
-
LASTFM_API_KEY = '
|
7
|
+
LASTFM_API_KEY = ''
|
8
8
|
|
9
9
|
def setup
|
10
10
|
@lastfm = GluttonLastfm.new LASTFM_API_KEY
|
11
11
|
end
|
12
12
|
|
13
|
-
def test_api_key_is_set
|
14
|
-
assert_not_equal(LASTFM_API_KEY, '<your last.fm API key>')
|
15
|
-
end
|
16
|
-
|
17
13
|
def test_object_creations
|
18
14
|
assert_equal(@lastfm.class, GluttonLastfm)
|
19
15
|
end
|
@@ -36,4 +32,69 @@ class TestGluttonLastfm < Test::Unit::TestCase
|
|
36
32
|
stub_get("http://ws.audioscrobbler.com/2.0?api_key=invalid_key&method=artist.getinfo&artist=Prince", 'invalid_api_key.xml', 403)
|
37
33
|
assert_raise(GluttonLastfm::Unauthorized) { lastfm_bad_key.artist_info('Prince') }
|
38
34
|
end
|
35
|
+
|
36
|
+
def test_can_handle_one_album_top_albums
|
37
|
+
stub_get("http://ws.audioscrobbler.com/2.0?api_key=#{LASTFM_API_KEY}&method=artist.gettopalbums&artist=Foxboro%20Hot%20Tubs", 'one_album_top_albums.xml')
|
38
|
+
one_album_top_albums = @lastfm.artist_top_albums('Foxboro Hot Tubs')
|
39
|
+
assert_equal(one_album_top_albums[0]['name'], 'Coolest Songs In The World! Vol. 7')
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_can_handle_multi_album_top_albums
|
43
|
+
stub_get("http://ws.audioscrobbler.com/2.0?api_key=#{LASTFM_API_KEY}&method=artist.gettopalbums&artist=Atmosphere", 'multi_album_top_albums.xml')
|
44
|
+
one_album_top_albums = @lastfm.artist_top_albums('Atmosphere')
|
45
|
+
assert_equal(one_album_top_albums[0]['name'], 'God Loves Ugly')
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_unknown_artist_top_albums
|
49
|
+
stub_get("http://ws.audioscrobbler.com/2.0?api_key=#{LASTFM_API_KEY}&method=artist.gettopalbums&artist=nowaytherebeanartistnamedthis", 'unknown_artist_top_albums.xml')
|
50
|
+
assert_raise(GluttonLastfm::QueryStatusFail) { @lastfm.artist_top_albums('nowaytherebeanartistnamedthis') }
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_artist_no_albums_top_albums
|
54
|
+
stub_get("http://ws.audioscrobbler.com/2.0?api_key=#{LASTFM_API_KEY}&method=artist.gettopalbums&artist=Wally%20Glutton", 'artist_no_albums_top_albums.xml')
|
55
|
+
top_albums = @lastfm.artist_top_albums('Wally Glutton')
|
56
|
+
assert_equal(top_albums.size, 0)
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_artist_no_tags_top_tags
|
60
|
+
stub_get("http://ws.audioscrobbler.com/2.0?api_key=#{LASTFM_API_KEY}&method=artist.gettoptags&artist=Wally%20Glutton", 'artist_no_tags_top_tags.xml')
|
61
|
+
top_tags = @lastfm.artist_top_tags('Wally Glutton')
|
62
|
+
assert_equal(top_tags.size, 0)
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_artist_multi_tags_top_tags
|
66
|
+
stub_get("http://ws.audioscrobbler.com/2.0?api_key=#{LASTFM_API_KEY}&method=artist.gettoptags&artist=Buck%2065", 'artist_multi_tags_top_tags.xml')
|
67
|
+
top_tags = @lastfm.artist_top_tags('Buck 65')
|
68
|
+
assert_equal(top_tags[0]['name'], 'Hip-Hop')
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_artist_no_events
|
72
|
+
stub_get("http://ws.audioscrobbler.com/2.0?api_key=#{LASTFM_API_KEY}&method=artist.getevents&artist=Wally%20Glutton", 'artist_no_events.xml')
|
73
|
+
events = @lastfm.artist_events('Wally Glutton')
|
74
|
+
assert_equal(events.size, 0)
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_unknown_artist_artist_search
|
78
|
+
stub_get("http://ws.audioscrobbler.com/2.0?api_key=#{LASTFM_API_KEY}&method=artist.search&artist=nowaytherebeanartistnamedthis", 'unknown_artist_artist_search.xml')
|
79
|
+
artists = @lastfm.artist_search('nowaytherebeanartistnamedthis')
|
80
|
+
assert_equal(artists.size, 0)
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_known_artist_artist_serach
|
84
|
+
stub_get("http://ws.audioscrobbler.com/2.0?api_key=#{LASTFM_API_KEY}&method=artist.search&artist=weakerthans", 'known_artist_artist_search.xml')
|
85
|
+
artists = @lastfm.artist_search('weakerthans')
|
86
|
+
assert_equal(artists[0]['name'], 'The Weakerthans')
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_unknown_album_album_search
|
90
|
+
stub_get("http://ws.audioscrobbler.com/2.0?api_key=#{LASTFM_API_KEY}&method=album.search&album=nowaytherebeanalbumnamedthis", 'unknown_album_album_search.xml')
|
91
|
+
albums = @lastfm.album_search('nowaytherebeanalbumnamedthis')
|
92
|
+
assert_equal(albums.size, 0)
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_known_album_album_serach
|
96
|
+
stub_get("http://ws.audioscrobbler.com/2.0?api_key=#{LASTFM_API_KEY}&method=album.search&album=vertex", 'known_album_album_search.xml')
|
97
|
+
albums = @lastfm.album_search('vertex')
|
98
|
+
assert_equal(albums[0]['name'], 'Vertex')
|
99
|
+
end
|
39
100
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 3
|
9
|
+
version: 0.1.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Wally Glutton
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-06-11 00:00:00 -05:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -66,7 +66,18 @@ files:
|
|
66
66
|
- glutton_lastfm.gemspec
|
67
67
|
- lib/glutton_lastfm.rb
|
68
68
|
- test/fixtures/artist_info_prince.xml
|
69
|
+
- test/fixtures/artist_multi_tags_top_tags.xml
|
70
|
+
- test/fixtures/artist_no_albums_top_albums.xml
|
71
|
+
- test/fixtures/artist_no_events.xml
|
72
|
+
- test/fixtures/artist_no_tags_top_tags.xml
|
69
73
|
- test/fixtures/invalid_api_key.xml
|
74
|
+
- test/fixtures/known_album_album_search.xml
|
75
|
+
- test/fixtures/known_artist_artist_search.xml
|
76
|
+
- test/fixtures/multi_album_top_albums.xml
|
77
|
+
- test/fixtures/one_album_top_albums.xml
|
78
|
+
- test/fixtures/unknown_album_album_search.xml
|
79
|
+
- test/fixtures/unknown_artist_artist_search.xml
|
80
|
+
- test/fixtures/unknown_artist_top_albums.xml
|
70
81
|
- test/helper.rb
|
71
82
|
- test/test_glutton_lastfm.rb
|
72
83
|
has_rdoc: true
|