Files
danbooru/test/test_helpers/download_test_helper.rb
evazion 2f61486ac6 sources: remove image_url method from base strategy.
Remove the `image_url` method from source strategies. This method would
return only the first image if a source had multiple images. The
`image_urls` method should be used instead. Tests were the main place
that still used `image_url` instead of `image_urls`.

Also make post replacements return an error if replacing with a source
that contains multiple images, instead of just blindly replacing the
post with the first image in the source.
2022-03-11 01:59:21 -06:00

18 lines
686 B
Ruby

module DownloadTestHelper
def assert_downloaded(expected_filesize, source, referer = nil)
strategy = Sources::Strategies.find(source, referer)
file = strategy.download_file!(strategy.image_urls.sole)
assert_equal(expected_filesize, file.size, "Tested source URL: #{source}")
end
def assert_rewritten(expected_source, test_source, test_referer = nil)
strategy = Sources::Strategies.find(test_source, test_referer)
rewritten_source = strategy.image_urls.sole
assert_match(expected_source, rewritten_source, "Tested source URL: #{test_source}")
end
def assert_not_rewritten(source, referer = nil)
assert_rewritten(source, source, referer)
end
end