tests: skip ugoira tests if ffmpeg/mkvmerge not installed.

This commit is contained in:
evazion
2019-09-01 13:10:37 -05:00
parent 3216f83ad8
commit 6e7b882dda
5 changed files with 22 additions and 30 deletions

View File

@@ -94,16 +94,15 @@ class UploadServiceTest < ActiveSupport::TestCase
end
should "work on an ugoira url" do
begin
file = subject.get_file_for_upload(@upload)
skip unless PixivUgoiraConverter.enabled?
file = subject.get_file_for_upload(@upload)
assert_not_nil(@upload.context["ugoira"])
assert_operator(File.size(file.path), :>, 0)
assert_not_nil(@upload.context["ugoira"])
assert_operator(File.size(file.path), :>, 0)
file.close
rescue Net::OpenTimeout
skip "network failure"
end
file.close
rescue Net::OpenTimeout
skip "network failure"
end
end
end
@@ -227,6 +226,8 @@ class UploadServiceTest < ActiveSupport::TestCase
end
should "generate a preview and a video" do
skip unless PixivUgoiraConverter.enabled?
preview, crop, sample = subject.generate_resizes(@file, @upload)
assert_operator(File.size(preview.path), :>, 0)
assert_operator(File.size(crop.path), :>, 0)
@@ -454,6 +455,8 @@ class UploadServiceTest < ActiveSupport::TestCase
end
should "download the file" do
skip unless PixivUgoiraConverter.enabled?
@service = subject.new(source: @source)
begin
@upload = @service.start!
@@ -848,7 +851,7 @@ class UploadServiceTest < ActiveSupport::TestCase
context "a post that is replaced by a ugoira" do
should "save the frame data" do
skip "ffmpeg not installed" unless check_ffmpeg
skip "ffmpeg not installed" unless PixivUgoiraConverter.enabled?
begin
as_user { @post.replace!(replacement_url: "http://www.pixiv.net/member_illust.php?mode=medium&illust_id=62247364") }
@post.reload
@@ -871,6 +874,8 @@ class UploadServiceTest < ActiveSupport::TestCase
context "a post that is replaced to another file then replaced back to the original file" do
should "not delete the original files" do
begin
skip unless PixivUgoiraConverter.enabled?
# this is called thrice to delete the file for 62247364
FileUtils.expects(:rm_f).times(3)
@@ -910,6 +915,8 @@ class UploadServiceTest < ActiveSupport::TestCase
# swap the images between @post1 and @post2.
begin
as_user do
skip unless PixivUgoiraConverter.enabled?
@post1.replace!(replacement_url: "https://www.pixiv.net/member_illust.php?mode=medium&illust_id=62247350")
@post2.replace!(replacement_url: "https://www.pixiv.net/member_illust.php?mode=medium&illust_id=62247364")
assert_equal("4ceadc314938bc27f3574053a3e1459a", @post1.md5)

View File

@@ -1,5 +1,3 @@
require 'ptools'
module DownloadTestHelper
def assert_downloaded(expected_filesize, source, referer=nil)
download = Downloads::File.new(source, referer)
@@ -33,8 +31,4 @@ module DownloadTestHelper
res = HTTParty.head(url, Danbooru.config.httparty_options.deep_merge(headers: headers))
assert_equal(size, res.content_length)
end
def check_ffmpeg
File.which("ffmpeg") && File.which("mkvmerge")
end
end