skip earlier on failed pixiv tests
This commit is contained in:
@@ -3,19 +3,10 @@ require 'ptools'
|
|||||||
module DownloadTestHelper
|
module DownloadTestHelper
|
||||||
def assert_downloaded(expected_filesize, source)
|
def assert_downloaded(expected_filesize, source)
|
||||||
download = Downloads::File.new(source)
|
download = Downloads::File.new(source)
|
||||||
@retry_count = 0
|
tempfile = download.download!
|
||||||
begin
|
|
||||||
tempfile = download.download!
|
|
||||||
rescue Net::OpenTimeout
|
|
||||||
@retry_count += 1
|
|
||||||
if @retry_count == 3
|
|
||||||
skip "Remote connection to #{source} failed"
|
|
||||||
else
|
|
||||||
sleep(@retry_count ** 2)
|
|
||||||
retry
|
|
||||||
end
|
|
||||||
end
|
|
||||||
assert_equal(expected_filesize, tempfile.size, "Tested source URL: #{source}")
|
assert_equal(expected_filesize, tempfile.size, "Tested source URL: #{source}")
|
||||||
|
rescue Net::OpenTimeout
|
||||||
|
skip "Remote connection to #{source} failed"
|
||||||
end
|
end
|
||||||
|
|
||||||
def assert_rewritten(expected_source, test_source)
|
def assert_rewritten(expected_source, test_source)
|
||||||
|
|||||||
@@ -2,39 +2,19 @@ require 'test_helper'
|
|||||||
|
|
||||||
class ArtistTest < ActiveSupport::TestCase
|
class ArtistTest < ActiveSupport::TestCase
|
||||||
def assert_artist_found(expected_name, source_url)
|
def assert_artist_found(expected_name, source_url)
|
||||||
tries = 0
|
artists = Artist.url_matches(source_url).to_a
|
||||||
|
|
||||||
begin
|
assert_equal(1, artists.size)
|
||||||
artists = Artist.url_matches(source_url).to_a
|
assert_equal(expected_name, artists.first.name, "Testing URL: #{source_url}")
|
||||||
|
rescue Net::OpenTimeout, PixivApiClient::Error
|
||||||
assert_equal(1, artists.size)
|
skip "Remote connection failed for #{source_url}"
|
||||||
assert_equal(expected_name, artists.first.name, "Testing URL: #{source_url}")
|
|
||||||
rescue Net::OpenTimeout, PixivApiClient::Error
|
|
||||||
tries += 1
|
|
||||||
if tries == 3
|
|
||||||
skip "Remote connection failed for #{source_url}"
|
|
||||||
else
|
|
||||||
sleep(tries ** 2)
|
|
||||||
retry
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def assert_artist_not_found(source_url)
|
def assert_artist_not_found(source_url)
|
||||||
tries = 0
|
artists = Artist.url_matches(source_url).to_a
|
||||||
|
assert_equal(0, artists.size, "Testing URL: #{source_url}")
|
||||||
begin
|
rescue Net::OpenTimeout
|
||||||
artists = Artist.url_matches(source_url).to_a
|
skip "Remote connection failed for #{source_url}"
|
||||||
assert_equal(0, artists.size, "Testing URL: #{source_url}")
|
|
||||||
rescue Net::OpenTimeout
|
|
||||||
tries += 1
|
|
||||||
if tries == 3
|
|
||||||
skip "Remote connection failed for #{source_url}"
|
|
||||||
else
|
|
||||||
sleep(tries ** 2)
|
|
||||||
retry
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context "An artist" do
|
context "An artist" do
|
||||||
|
|||||||
@@ -4,26 +4,15 @@ module Sources
|
|||||||
class PixivTest < ActiveSupport::TestCase
|
class PixivTest < ActiveSupport::TestCase
|
||||||
def get_source(source)
|
def get_source(source)
|
||||||
@site = Sources::Site.new(source)
|
@site = Sources::Site.new(source)
|
||||||
|
@site.get
|
||||||
begin
|
|
||||||
@site.get
|
|
||||||
rescue Net::OpenTimeout
|
|
||||||
@retry_count += 1
|
|
||||||
if @retry_count == 3
|
|
||||||
skip "Could not connect to Pixiv"
|
|
||||||
else
|
|
||||||
sleep(@retry_count ** 2)
|
|
||||||
retry
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
@site
|
@site
|
||||||
|
rescue Net::OpenTimeout
|
||||||
|
skip "Remote connection to #{source} failed"
|
||||||
end
|
end
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
super
|
super
|
||||||
load_pixiv_tokens!
|
load_pixiv_tokens!
|
||||||
@retry_count = 0
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def teardown
|
def teardown
|
||||||
|
|||||||
Reference in New Issue
Block a user