tests: skip ugoira tests if ffmpeg/mkvmerge not installed.
This commit is contained in:
1
Gemfile
1
Gemfile
@@ -37,7 +37,6 @@ gem 'httparty'
|
||||
gem 'rakismet'
|
||||
gem 'recaptcha', require: "recaptcha/rails"
|
||||
gem 'activemodel-serializers-xml'
|
||||
gem 'ptools'
|
||||
gem 'jquery-rails'
|
||||
gem 'webpacker', '>= 4.0.x'
|
||||
gem 'retriable'
|
||||
|
||||
14
Gemfile.lock
14
Gemfile.lock
@@ -152,8 +152,6 @@ GEM
|
||||
ffaker (2.12.0)
|
||||
ffi (1.11.1)
|
||||
ffi (1.11.1-x64-mingw32)
|
||||
ffi-win32-extensions (1.0.3)
|
||||
ffi
|
||||
flamegraph (0.9.5)
|
||||
get_process_mem (0.2.4)
|
||||
ffi (~> 1.0)
|
||||
@@ -290,9 +288,6 @@ GEM
|
||||
unicode (~> 0.4.4)
|
||||
pry-rails (0.3.9)
|
||||
pry (>= 0.10.4)
|
||||
ptools (1.3.5)
|
||||
ptools (1.3.5-universal-mingw32)
|
||||
win32-file (>= 0.7.0)
|
||||
public_suffix (3.1.1)
|
||||
rack (2.0.7)
|
||||
rack-contrib (2.1.0)
|
||||
@@ -440,14 +435,6 @@ GEM
|
||||
websocket-extensions (0.1.4)
|
||||
whenever (1.0.0)
|
||||
chronic (>= 0.6.3)
|
||||
win32-file (0.8.2)
|
||||
ffi
|
||||
ffi-win32-extensions
|
||||
win32-file-stat (>= 1.4.0)
|
||||
win32-file-stat (1.5.5)
|
||||
ffi
|
||||
ffi-win32-extensions
|
||||
win32console (1.3.2)
|
||||
zeitwerk (2.1.9)
|
||||
|
||||
PLATFORMS
|
||||
@@ -496,7 +483,6 @@ DEPENDENCIES
|
||||
pry-byebug
|
||||
pry-inline
|
||||
pry-rails
|
||||
ptools
|
||||
rack-mini-profiler
|
||||
rails (~> 6.0)
|
||||
rakismet
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
class PixivUgoiraConverter
|
||||
def self.enabled?
|
||||
system("type -p ffmpeg > /dev/null") && system("type -p mkvmerge > /dev/null")
|
||||
end
|
||||
|
||||
def self.generate_webm(ugoira_file, frame_data)
|
||||
raise NotImplementedError, "can't convert ugoira to webm: ffmpeg or mkvmerge not installed" unless enabled?
|
||||
|
||||
folder = Zip::File.new(ugoira_file.path)
|
||||
output_file = Tempfile.new(binmode: true)
|
||||
write_path = output_file.path
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user