Enable spec fo and fix youtube upload signing function. VRFS-2032

This commit is contained in:
Steven Miers 2014-10-30 20:47:28 -05:00
parent 47415c27d3
commit 80be3c572f
3 changed files with 30 additions and 33 deletions

View File

@ -131,43 +131,35 @@ module JamRuby
}
)
puts result.inspect
# Response should something look like:
# HTTP/1.1 200 OK
# Location: https://www.googleapis.com/upload/youtube/v3/videos?uploadType=resumable&upload_id=xa298sd_f&part=snippet,status,contentDetails
# Content-Length: 0
puts "RESPONSE [#{result.inspect}]"
if result.body.nil? || result.body.blank?
raise "Result not in correct form: [#{result.body}]"
if (result.nil? || result.status!=200 || result.headers['location'].blank?)
msg = "Failed signing with status=#{result.status} #{result.inspect}: "
if result.body.present? && result.body.length > 2
msg << result.body.inspect# JSON.parse(result.body).inspect
end
# TODO: how to test for this:
# If reason is "youtubeSignupRequired"
# If the user's youtube account is unlinked, they'll have to go here.
# http://m.youtube.com/create_channel. With v3, there is no automated way to do this.
raise msg
else
# This has everything one needs to start the upload to youtube:
{
"method" => "PUT",
"url" => result.headers['location'],
"Authorization" => "Bearer #{auth.token}",
"Content-Length" => length,
"Content-Type" => "video/*"
}
end
lines = result.body.split("\n")
if lines.length !=3
raise "Result not in correct form: [#{lines.length}] : #{lines.inspect}"
end
first_line = lines.first.split(" ")
if first_line.length !=3
raise "First line not in correct form: [#{first_line}]"
end
status = first_line[1].to_i
if (status != 200)
raise "Status from youtube: #{status}"
end
location_url = lines[1].split(":").last().strip()
# This has everything one needs to start the upload to youtube:
{
"method"=> "PUT",
"url"=> location_url,
"Authorization"=> "Bearer #{auth.token}",
"Content-Length"=> length,
"Content-Type"=> "video/*"
}
# This has everything one needs to start the upload to youtube:
end
# https://developers.google.com/youtube/v3/guides/using_resumable_upload_protocol#Check_Upload_Status

View File

@ -36,11 +36,10 @@ describe "YouTube", :js=>true, :type => :feature, :capybara_feature => true do
end
it "should retrieve upload url" do
pending "fix this"
length = 3276
upload_hash=@youtube_client.upload_sign(@user, "test_video.mp4", length)
upload_hash.should_not be_nil
upload_hash.length.should gte(1)
upload_hash.length.should be >=1
upload_hash['method'].should eq("PUT")
upload_hash['url'].should_not be_nil
upload_hash['Authorization'].should_not be_nil
@ -56,7 +55,7 @@ describe "YouTube", :js=>true, :type => :feature, :capybara_feature => true do
upload_hash=@youtube_client.upload_sign(@user, "test_video.mp4", length)
puts upload_hash.inspect
upload_hash.should_not be_nil
upload_hash.length.should gte(1)
upload_hash.length.should be >=1
upload_hash['method'].should eq("PUT")
upload_hash['url'].should_not be_nil
upload_hash['Authorization'].should_not be_nil

View File

@ -19,4 +19,10 @@ Getting an access token for the purposes of automated testing is tricky, but pos
Notes:
* When authenticating, client_id is required by several of the APIs. However, this doesn't work for /o/oauth2/token. What actually works is the "email" value from the developer console. This is now saved in the app as well.
The tests in question use the following credentials:
u: jamkazamtest@gmail.com
p: stinkyblueberryjam
Also, a server is started on port 2112, as 3000 was already being used on the build server.