tests: fix broken source tests.

Fix various tests broken by source files changing or being deleted.
This commit is contained in:
evazion
2020-11-10 14:38:17 -06:00
parent 3ce8c7f004
commit cc64f8b7ee
6 changed files with 24 additions and 21 deletions

View File

@@ -116,7 +116,7 @@ module Downloads
should "download new novel images" do
@file_url = "https://i.pximg.net/novel-cover-original/img/2017/07/27/23/14/17/8465454_80685d10e6df4d7d53ad347ddc18a36b.jpg"
@ref = 'https://www.pixiv.net/novel/show.php?id=8465454&mode=cover'
@file_size = 532_129
@file_size = 532_037
assert_not_rewritten(@file_url, @ref)
assert_downloaded(@file_size, @file_url, @ref)

View File

@@ -4,10 +4,11 @@ module Sources
class NewGroundsTest < ActiveSupport::TestCase
context "The source for a newgrounds picture" do
setup do
@url = "https://www.newgrounds.com/art/view/natthelich/fire-emblem-marth-plus-progress-pic"
@comment = "https://art.ngfiles.com/comments/57000/iu_57615_7115981.jpg"
@url = "https://www.newgrounds.com/art/view/natthelich/d-d-light-domain-cleric-nathaniel-8"
@image_url = "https://art.ngfiles.com/images/1138000/1138016_natthelich_d-d-light-domain-cleric-nathaniel-8.png?f1578591058"
@comment = "https://art.ngfiles.com/comments/84000/iu_84427_7115981.jpg"
@image_1 = Sources::Strategies.find(@url)
@image_2 = Sources::Strategies.find("https://art.ngfiles.com/images/1033000/1033622_natthelich_fire-emblem-marth-plus-progress-pic.png?f1569487181")
@image_2 = Sources::Strategies.find(@image_url)
@image_3 = Sources::Strategies.find(@comment, @url)
end
@@ -18,9 +19,9 @@ module Sources
end
should "get the artist commentary title" do
assert_equal("Fire Emblem - Marth (plus progress pic)", @image_1.artist_commentary_title)
assert_equal("Fire Emblem - Marth (plus progress pic)", @image_2.artist_commentary_title)
assert_equal("Fire Emblem - Marth (plus progress pic)", @image_3.artist_commentary_title)
assert_equal("D&D - Light Domain Cleric, Nathaniel", @image_1.artist_commentary_title)
assert_equal("D&D - Light Domain Cleric, Nathaniel", @image_2.artist_commentary_title)
assert_equal("D&D - Light Domain Cleric, Nathaniel", @image_3.artist_commentary_title)
end
should "get profile url" do
@@ -30,10 +31,10 @@ module Sources
end
should "get the image urls" do
assert_match(%r{https?://art\.ngfiles\.com/images/1033000/1033622_natthelich_fire-emblem-marth-plus-progress-pic\.png(?:\?\w+)?}i, @image_1.image_url)
assert_match(%r{https://art.ngfiles.com/images/1138000/1138016_natthelich_d-d-light-domain-cleric-nathaniel-8.png}i, @image_1.image_url)
assert_includes(@image_1.image_urls, @comment)
assert_match(%r{https?://art\.ngfiles\.com/images/1033000/1033622_natthelich_fire-emblem-marth-plus-progress-pic\.png(?:\?\w+)?}i, @image_2.image_url)
assert_match(%r{https://art.ngfiles.com/images/1138000/1138016_natthelich_d-d-light-domain-cleric-nathaniel-8.png}i, @image_2.image_url)
assert_equal(@comment, @image_3.image_url)
end
@@ -44,16 +45,18 @@ module Sources
end
should "download an image" do
assert_downloaded(630365, @image_1.image_url)
assert_downloaded(630365, @image_2.image_url)
assert_downloaded(129033, @image_3.image_url)
assert_downloaded(1195723, @image_1.image_url)
assert_downloaded(1195723, @image_2.image_url)
assert_downloaded(158058, @image_3.image_url)
end
should "get the tags" do
tags = [
%w[fire-emblem https://www.newgrounds.com/search/conduct/art?match=tags&tags=fire-emblem],
%w[marth https://www.newgrounds.com/search/conduct/art?match=tags&tags=marth ]
%w[cleric https://www.newgrounds.com/search/conduct/art?match=tags&tags=cleric],
%w[nathaniel https://www.newgrounds.com/search/conduct/art?match=tags&tags=nathaniel],
%w[oc https://www.newgrounds.com/search/conduct/art?match=tags&tags=oc]
]
assert_equal(tags, @image_1.tags)
assert_equal(tags, @image_2.tags)
assert_equal(tags, @image_3.tags)

View File

@@ -98,7 +98,7 @@ module Sources
end
should "get the remote image size" do
assert_equal(854_653, @site.remote_size)
assert_equal(863_758, @site.remote_size)
end
should "get the full size image url" do

View File

@@ -135,9 +135,9 @@ class UploadServiceTest < ActiveSupport::TestCase
@upload = @service.start!
assert_equal("preprocessed", @upload.status)
assert_equal(294591, @upload.file_size)
assert_equal(317733, @upload.file_size)
assert_equal("jpg", @upload.file_ext)
assert_equal("3cb1ef624714c15dbb2d6e7b1d57faef", @upload.md5)
assert_equal("4c71da5638b897aa6da1150e742e2982", @upload.md5)
assert(File.exist?(Danbooru.config.storage_manager.file_path(@upload.md5, "jpg", :original)))
assert(File.exist?(Danbooru.config.storage_manager.file_path(@upload.md5, "jpg", :preview)))
end