tests: fix upload tests.

This commit is contained in:
evazion
2018-03-19 23:17:24 -05:00
parent 41a4ff15cd
commit d089be9f8a
13 changed files with 96 additions and 273 deletions

View File

@@ -5,9 +5,7 @@ module Downloads
context "a download for a (small) artstation image" do
setup do
@source = "https://cdnb3.artstation.com/p/assets/images/images/003/716/071/large/aoi-ogata-hate-city.jpg?1476754974"
@tempfile = Tempfile.new("danbooru-test")
@download = Downloads::File.new(@source, @tempfile.path)
@download.download!
@download = Downloads::File.new(@source)
end
should "download the large image instead" do
@@ -18,8 +16,7 @@ module Downloads
context "for an image where an original does not exist" do
setup do
@source = "https://cdna.artstation.com/p/assets/images/images/004/730/278/large/mendel-oh-dragonll.jpg"
@tempfile = Tempfile.new("danbooru-test")
@download = Downloads::File.new(@source, @tempfile.path)
@download = Downloads::File.new(@source)
@download.download!
end
@@ -38,8 +35,7 @@ module Downloads
context "a download for a https://$artist.artstation.com/projects/$id page" do
setup do
@source = "https://dantewontdie.artstation.com/projects/YZK5q"
@tempfile = Tempfile.new("danbooru-test")
@download = Downloads::File.new(@source, @tempfile.path)
@download = Downloads::File.new(@source)
@download.download!
end

View File

@@ -5,9 +5,8 @@ module Downloads
context "a download for a deviant art html page" do
setup do
@source = "http://starbitt.deviantart.com/art/09271X-636962118"
@tempfile = Tempfile.new("danbooru-test")
@download = Downloads::File.new(@source, @tempfile.path)
@download.download!
@download = Downloads::File.new(@source)
@tempfile = @download.download!
end
should "set the html page as the source" do

View File

@@ -5,12 +5,7 @@ module Downloads
context "A twitter video download" do
setup do
@source = "https://twitter.com/CincinnatiZoo/status/859073537713328129"
@tempfile = Tempfile.new("danbooru-test")
@download = Downloads::File.new(@source, @tempfile.path)
end
teardown do
@tempfile.close
@download = Downloads::File.new(@source)
end
should "preserve the twitter source" do
@@ -22,12 +17,8 @@ module Downloads
context "A post download" do
setup do
@source = "http://www.google.com/intl/en_ALL/images/logo.gif"
@download = Downloads::File.new(@source)
@tempfile = Tempfile.new("danbooru-test")
@download = Downloads::File.new(@source, @tempfile.path)
end
teardown do
@tempfile.close
end
context "that fails" do
@@ -49,10 +40,9 @@ module Downloads
end
should "store the file in the tempfile path" do
@download.download!
tempfile = @download.download!
assert_equal(@source, @download.source)
assert(::File.exists?(@tempfile.path), "temp file should exist")
assert(::File.size(@tempfile.path) > 0, "should have data")
assert_operator(tempfile.size, :>, 0, "should have data")
end
end
end

View File

@@ -4,13 +4,9 @@ module Downloads
class PixivTest < ActiveSupport::TestCase
context "An ugoira site for pixiv" do
setup do
@tempfile = Tempfile.new("danbooru-test")
@download = Downloads::File.new("http://www.pixiv.net/member_illust.php?mode=medium&illust_id=62247364", @tempfile.path)
@download.download!
end
teardown do
@tempfile.unlink
@download = Downloads::File.new("http://www.pixiv.net/member_illust.php?mode=medium&illust_id=62247364")
@tempfile = @download.download!
@tempfile.close!
end
should "capture the data" do