diff --git a/test/test_helpers/download_test_helper.rb b/test/test_helpers/download_test_helper.rb index 2552e91ce..95cd9e51d 100644 --- a/test/test_helpers/download_test_helper.rb +++ b/test/test_helpers/download_test_helper.rb @@ -3,19 +3,10 @@ require 'ptools' module DownloadTestHelper def assert_downloaded(expected_filesize, source) download = Downloads::File.new(source) - @retry_count = 0 - 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 + tempfile = download.download! assert_equal(expected_filesize, tempfile.size, "Tested source URL: #{source}") + rescue Net::OpenTimeout + skip "Remote connection to #{source} failed" end def assert_rewritten(expected_source, test_source) diff --git a/test/unit/artist_test.rb b/test/unit/artist_test.rb index 574174d5d..c0ce04e9d 100644 --- a/test/unit/artist_test.rb +++ b/test/unit/artist_test.rb @@ -2,39 +2,19 @@ require 'test_helper' class ArtistTest < ActiveSupport::TestCase def assert_artist_found(expected_name, source_url) - tries = 0 + artists = Artist.url_matches(source_url).to_a - begin - artists = Artist.url_matches(source_url).to_a - - assert_equal(1, artists.size) - 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 + assert_equal(1, artists.size) + assert_equal(expected_name, artists.first.name, "Testing URL: #{source_url}") + rescue Net::OpenTimeout, PixivApiClient::Error + skip "Remote connection failed for #{source_url}" end def assert_artist_not_found(source_url) - tries = 0 - - begin - artists = Artist.url_matches(source_url).to_a - 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 + artists = Artist.url_matches(source_url).to_a + assert_equal(0, artists.size, "Testing URL: #{source_url}") + rescue Net::OpenTimeout + skip "Remote connection failed for #{source_url}" end context "An artist" do diff --git a/test/unit/sources/pixiv_test.rb b/test/unit/sources/pixiv_test.rb index 173d3e778..0eb5a6bc0 100644 --- a/test/unit/sources/pixiv_test.rb +++ b/test/unit/sources/pixiv_test.rb @@ -4,26 +4,15 @@ module Sources class PixivTest < ActiveSupport::TestCase def get_source(source) @site = Sources::Site.new(source) - - 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.get @site + rescue Net::OpenTimeout + skip "Remote connection to #{source} failed" end def setup super load_pixiv_tokens! - @retry_count = 0 end def teardown