Skip to content
Browse files

issue 10, added tracks method, fixed playlist tests

  • Loading branch information...
1 parent ad71d6a commit e00fe755f0df5379065650c404616ab2938c6f1d @spudtrooper committed May 7, 2012
Showing with 83 additions and 11 deletions.
  1. +1 −1 Makefile
  2. +7 −0 lib/rdio/types.rb
  3. +5 −0 test/common.rb
  4. +18 −0 test/test_jewgonewild.rb
  5. +27 −9 test/test_playlist.rb
  6. +24 −0 test/test_playlist_add_delete.rb
  7. +1 −1 test/test_search.rb
View
2 Makefile
@@ -1,5 +1,5 @@
NAME=rdio
-VERSION=0.0.98b
+VERSION=0.0.99
DATE=$(shell date +"%Y-%m-%d")
.PHONY: test
View
7 lib/rdio/types.rb
@@ -338,6 +338,13 @@ def remove(index,count,tracks)
api.removeFromPlaylist self,index,count,tracks
end
+ # Returns an array of tracks
+ def tracks
+ ids = track_keys
+ return [] if not ids
+ return ids.map {|id| Track.get id}
+ end
+
# Returns an array of Playlist for the query and other params
def self.search(query,never_or=nil,extras=nil,start=nil,count=nil)
extras = Rdio::add_to_array extras,'playlists'
View
5 test/common.rb
@@ -45,6 +45,11 @@ def other_setup
def teardown
Rdio.reset
+ other_teardown
+ end
+
+ def other_teardown
+ # nothing
end
def test_default_test
View
18 test/test_jewgonewild.rb
@@ -0,0 +1,18 @@
+require File.dirname(__FILE__) + '/common'
+include Rdio
+
+#
+# https://github.com/spudtrooper/rdiorb/issues/10
+#
+class TestJewGoneWild < TestCase
+
+ def test_search_Jewgonewild
+ Rdio::reset
+ key = ENV['RDIO_KEY']
+ secret = ENV['RDIO_SECRET']
+ rdio = Rdio::init(key,secret)
+ res = rdio.search('yellow ostrich')
+ assert_equal 10,res.length # should be at least 10
+ end
+
+end
View
36 test/test_playlist.rb
@@ -3,10 +3,27 @@
class TestPlaylist < RdioTestCase
+ @playlist = nil
+ @playlist_key = nil
+
+ def other_setup
+ name = 'test playlist'
+ desc = 'description for test playlist'
+ tracks = [Track.get 't5483181']
+ playlist = Playlist.create name,desc,tracks,'trackKeys'
+ assert_not_nil playlist
+ @playlist = playlist
+ @playlist_key = playlist.key
+ end
+
+ def other_teardown
+ @playlist.delete
+ end
+
def test_big_icon
playlist = Playlist.get 'p3917','bigIcon'
- long_url = 'http://m.rdio.com/_is/?aid=154083,211660&w=600&h=600'
- assert_equal long_url,playlist.big_icon
+ long_url_start = 'http://m.rdio.com/_is/?aid=154083'
+ assert_not_nil playlist.big_icon.index long_url_start
end
def test_track_keys
@@ -15,24 +32,25 @@ def test_track_keys
assert_not_nil track_keys.index 't1851082t2560085'
end
- def test_collaborating
- playlist = Playlist.get 'p158060'
- playlist.collaborating = true
- end
+
+ def test_collaborating
+ playlist = Playlist.get @playlist_key
+ playlist.collaborating = true
+ end
def test_collaboration_mode
- playlist = Playlist.get 'p158060'
+ playlist = Playlist.get @playlist_key
playlist.collaboration_mode = 1
end
def test_track_keys
- playlist = Playlist.get 'p158060','trackKeys'
+ playlist = Playlist.get @playlist_key,'trackKeys'
track_keys = ['t5734430','t5734492']
playlist.order = track_keys
end
def test_set_fields
- playlist = Playlist.get 'p158060'
+ playlist = Playlist.get @playlist_key
playlist.set_fields 'the name','the description'
end
View
24 test/test_playlist_add_delete.rb
@@ -0,0 +1,24 @@
+require File.dirname(__FILE__) + '/common'
+include Rdio
+
+class TestPlaylist < RdioTestCase
+
+ def test_add_delete
+ name = 'test playlist'
+ desc = 'description for test playlist'
+ tracks = [Track.get 't5483181']
+ playlist = Playlist.create name,desc,tracks,'trackKeys'
+ assert_not_nil playlist
+
+ have = playlist.tracks
+ want = tracks
+ assert_equal want.length,have.length
+ assert_equal want[0].name,have[0].name
+
+ assert_equal name,playlist.name
+
+ assert_not_nil playlist.delete
+ end
+
+
+end
View
2 test/test_search.rb
@@ -91,5 +91,5 @@ def test_search_generic
res = Search.search 'cat'
assert_at_least 10,res.length,'length'
end
-
+
end

0 comments on commit e00fe75

Please sign in to comment.
Something went wrong with that request. Please try again.