integrate ugoira converted into upload flow
This commit is contained in:
1078
test/fixtures/vcr_cassettes/ugoira-converter.yml
vendored
1078
test/fixtures/vcr_cassettes/ugoira-converter.yml
vendored
File diff suppressed because it is too large
Load Diff
@@ -4,28 +4,6 @@ class PixivUgoiraConverterTest < ActiveSupport::TestCase
|
||||
context "An ugoira converter" do
|
||||
setup do
|
||||
@url = "http://www.pixiv.net/member_illust.php?mode=medium&illust_id=46378654"
|
||||
@agent = begin
|
||||
mech = Mechanize.new
|
||||
|
||||
phpsessid = Cache.get("pixiv-phpsessid")
|
||||
if phpsessid
|
||||
cookie = Mechanize::Cookie.new("PHPSESSID", phpsessid)
|
||||
cookie.domain = ".pixiv.net"
|
||||
cookie.path = "/"
|
||||
mech.cookie_jar.add(cookie)
|
||||
else
|
||||
mech.get("http://www.pixiv.net") do |page|
|
||||
page.form_with(:action => "/login.php") do |form|
|
||||
form['pixiv_id'] = Danbooru.config.pixiv_login
|
||||
form['pass'] = Danbooru.config.pixiv_password
|
||||
end.click_button
|
||||
end
|
||||
phpsessid = mech.cookie_jar.cookies.select{|c| c.name == "PHPSESSID"}.first
|
||||
Cache.put("pixiv-phpsessid", phpsessid.value, 1.month) if phpsessid
|
||||
end
|
||||
|
||||
mech
|
||||
end
|
||||
@write_file = Tempfile.new("output")
|
||||
end
|
||||
|
||||
@@ -34,27 +12,27 @@ class PixivUgoiraConverterTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
should "output to gif" do
|
||||
@converter = PixivUgoiraConverter.new(@agent, @url, @write_file.path, :gif)
|
||||
@converter = PixivUgoiraConverter.new(@url, @write_file.path, :gif)
|
||||
VCR.use_cassette("ugoira-converter", :record => :new_episodes) do
|
||||
@converter.process
|
||||
@converter.process!
|
||||
end
|
||||
assert_operator(File.size(@converter.write_path), :>, 1_000)
|
||||
end
|
||||
|
||||
should "output to webm" do
|
||||
@converter = PixivUgoiraConverter.new(@agent, @url, @write_file.path, :webm)
|
||||
@converter = PixivUgoiraConverter.new(@url, @write_file.path, :webm)
|
||||
VCR.use_cassette("ugoira-converter", :record => :new_episodes) do
|
||||
@converter.process
|
||||
@converter.process!
|
||||
end
|
||||
assert_operator(File.size(@converter.write_path), :>, 1_000)
|
||||
end
|
||||
|
||||
should "output to apng" do
|
||||
@converter = PixivUgoiraConverter.new(@agent, @url, @write_file.path, :apng)
|
||||
VCR.use_cassette("ugoira-converter", :record => :new_episodes) do
|
||||
@converter.process
|
||||
end
|
||||
assert_operator(File.size(@converter.write_path), :>, 1_000)
|
||||
end
|
||||
# should "output to apng" do
|
||||
# @converter = PixivUgoiraConverter.new(@url, @write_file.path, :apng)
|
||||
# VCR.use_cassette("ugoira-converter", :record => :new_episodes) do
|
||||
# @converter.process!
|
||||
# end
|
||||
# assert_operator(File.size(@converter.write_path), :>, 1_000)
|
||||
# end
|
||||
end
|
||||
end
|
||||
@@ -101,6 +101,21 @@ class UploadTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
context "downloader" do
|
||||
context "that is an ugoira" do
|
||||
setup do
|
||||
@url = "http://www.pixiv.net/member_illust.php?mode=medium&illust_id=46378654"
|
||||
@upload = FactoryGirl.create(:source_upload, :source => @url, :tag_string => "ugoira")
|
||||
@output_path = "#{Rails.root}/tmp/test.download.webm"
|
||||
end
|
||||
|
||||
should "process successfully" do
|
||||
VCR.use_cassette("ugoira-converter", :record => :new_episodes) do
|
||||
@upload.download_from_source(@output_path)
|
||||
end
|
||||
assert_operator(File.size(@output_path), :>, 1_000)
|
||||
end
|
||||
end
|
||||
|
||||
should "initialize the final path after downloading a file" do
|
||||
@upload = FactoryGirl.create(:source_upload)
|
||||
path = "#{Rails.root}/tmp/test.download.jpg"
|
||||
|
||||
Reference in New Issue
Block a user