require File.dirname(__FILE__) + '/test_helper.rb' class TestTunecoreDirect < Test::Unit::TestCase def setup TunecoreDirect::Base.tunecore_server = "http://test.tunecore.com" TunecoreDirect::Base.api_key = "testkey" #random email address so we dont get collisions after the first test chars = ["A".."Z","a".."z","0".."9"].collect { |r| r.to_a }.join @email = (1..8).collect { chars[rand(chars.size)] }.pack("C*") + "@domain.com" end def test_can_create_person person = TunecoreDirect::Person.new person.name = "Joe Schmoe" person.email = @email person.password = "my_pas$word" person.phone_number = "212-555-1212" person.country = "United States" person.postal_code = "11201" created = person.create assert created == true end def test_can_create_person_and_album_and_song # create the person person = TunecoreDirect::Person.new person.name = "Joe Schmoe" person.email = @email person.password = "my_pas$word" person.phone_number = "212-555-1212" person.country = "United States" person.postal_code = "11201" assert person.create # create the album album = TunecoreDirect::Album.new album.name = "My Album" album.person_id = person.person_id album.orig_release_date = "2008-02-23" album.sale_date = "2008-02-23" album.primary_genre = "Rock" album.secondary_genre = "Alternative" album.artist_name = "Alex Kane" album.label_name = "Shochu" album.c_copyright = "1999" album.p_copyright = "1999" album.recording_location = "Brooklyn" album.parental_advisory = false album.stores = "iTunesUS,iTunesAU,iTunesCA,iTunesEU,iTunesJP,iTunesEU,RhapsodyRH,MusicNet,Napster,eMusic,Amazon,Lala" created = album.create assert created == true #create the song song = TunecoreDirect::Song.new song.album_id = album.album_id song.name = "My song" song.track_num = 1 song.asset_url = "http://s3.amazonaws.com/my_bucket/track_01.mp3" assert song.save == true # get all albums albums = TunecoreDirect::Album.get_all assert albums.size > 0 # takedown the first album album_id = albums.first.album_id assert TunecoreDirect::Album.takedown( album_id ) != nil # get person by email person = TunecoreDirect::Person.get(@email) assert person.email = @email # get all the songs for this album songs = person.albums.first.songs end end