tests: factor out assert_downloaded to DownloadTestHelper.
This commit is contained in:
@@ -2,29 +2,6 @@ require 'test_helper'
|
||||
|
||||
module Downloads
|
||||
class PixivTest < ActiveSupport::TestCase
|
||||
def assert_downloaded(expected_filesize, source)
|
||||
tempfile = Tempfile.new("danbooru-test")
|
||||
download = Downloads::File.new(source, tempfile.path)
|
||||
|
||||
assert_nothing_raised(Downloads::File::Error) do
|
||||
download.download!
|
||||
end
|
||||
|
||||
assert_equal(expected_filesize, tempfile.size, "Tested source URL: #{source}")
|
||||
end
|
||||
|
||||
def assert_rewritten(expected_source, test_source)
|
||||
tempfile = Tempfile.new("danbooru-test")
|
||||
download = Downloads::File.new(test_source, tempfile.path)
|
||||
|
||||
rewritten_source, headers, _ = download.before_download(test_source, {}, {})
|
||||
assert_equal(expected_source, rewritten_source, "Tested source URL: #{test_source}")
|
||||
end
|
||||
|
||||
def assert_not_rewritten(source)
|
||||
assert_rewritten(source, source)
|
||||
end
|
||||
|
||||
context "An ugoira site for pixiv" do
|
||||
setup do
|
||||
@tempfile = Tempfile.new("danbooru-test")
|
||||
|
||||
Reference in New Issue
Block a user