tests: fix broken tests.

This commit is contained in:
evazion
2022-08-23 18:31:24 -05:00
parent 09dfab1f0d
commit e3af738371
16 changed files with 100 additions and 152 deletions

View File

@@ -33,37 +33,18 @@ module Sources
end
end
context "The source site for an art station projects page" do
setup do
@site = Source::Extractor.find("https://dantewontdie.artstation.com/projects/YZK5q")
end
should "get the image url" do
url = "https://cdn.artstation.com/p/assets/images/images/006/066/534/4k/yinan-cui-reika.jpg?1495781565"
assert_equal([url], @site.image_urls)
end
should "get the page url" do
assert_equal("https://dantewontdie.artstation.com/projects/YZK5q", @site.page_url)
end
should "get the profile" do
assert_equal("https://www.artstation.com/dantewontdie", @site.profile_url)
end
should "get the artist name" do
assert_equal("dantewontdie", @site.artist_name)
end
should "get the tags" do
assert_equal(%w[gantz Reika], @site.tags.map(&:first))
assert_equal(%w[gantz reika], @site.normalized_tags)
end
should "get the artist commentary" do
assert_equal("Reika ", @site.artist_commentary_title)
assert_equal("From Gantz.", @site.dtext_artist_commentary_desc)
end
context "An ArtStation /projects/ URL" do
strategy_should_work(
"https://dantewontdie.artstation.com/projects/YZK5q",
image_urls: ["https://cdn.artstation.com/p/assets/images/images/006/066/534/4k/yinan-cui-reika.jpg?1495781565"],
page_url: "https://dantewontdie.artstation.com/projects/YZK5q",
profile_url: "https://www.artstation.com/dantewontdie",
artist_name: "dantewontdie",
tags: %w[gantz Reika],
artist_commentary_title: "Reika ",
dtext_artist_commentary_desc: "From Gantz.",
download_size: 210_899,
)
end
context "The source site for a www.artstation.com/artwork/$slug page" do
@@ -182,6 +163,30 @@ module Sources
end
end
context "A /small/ ArtStation image URL" do
strategy_should_work(
"https://cdnb3.artstation.com/p/assets/images/images/003/716/071/small/aoi-ogata-hate-city.jpg?1476754974",
image_urls: ["https://cdn.artstation.com/p/assets/images/images/003/716/071/4k/aoi-ogata-hate-city.jpg?1476754974"],
download_size: 1_816_628,
)
end
context "A /large/ ArtStation image URL (1)" do
strategy_should_work(
"https://cdnb.artstation.com/p/assets/images/images/003/716/071/large/aoi-ogata-hate-city.jpg?1476754974",
image_urls: ["https://cdn.artstation.com/p/assets/images/images/003/716/071/4k/aoi-ogata-hate-city.jpg?1476754974"],
download_size: 1_816_628,
)
end
context "A /large/ ArtStation image URL (2)" do
strategy_should_work(
"https://cdna.artstation.com/p/assets/images/images/004/730/278/large/mendel-oh-dragonll.jpg",
image_urls: ["https://cdn.artstation.com/p/assets/images/images/004/730/278/4k/mendel-oh-dragonll.jpg"],
download_size: 452_985,
)
end
should "work for artists with underscores in their name" do
site = Source::Extractor.find("https://hosi_na.artstation.com/projects/3oEk3B")
assert_equal("hosi_na", site.artist_name)

View File

@@ -211,9 +211,16 @@ module Sources
context "A source with malformed links in the artist commentary" do
should "fix the links" do
@site = Source::Extractor.find("https://teemutaiga.deviantart.com/art/Kisu-620666655")
@site = Source::Extractor.find("https://www.deviantart.com/dishwasher1910/art/Solar-Sisters-792488305")
assert_match(%r{"Print available at Inprnt":\[http://www.inprnt.com/gallery/teemutaiga/kisu\]}, @site.dtext_artist_commentary_desc)
assert_equal(<<~EOS.chomp, @site.dtext_artist_commentary_desc)
Solar sisters
HD images , Psd file and alternative version available on my Patreon :
"www.patreon.com/Dishwasher1910":[https://www.patreon.com/Dishwasher1910]
You can buy the print here :
"www.inprnt.com/gallery/dishwas…":[https://www.inprnt.com/gallery/dishwasher1910/solar-sisters/]
EOS
end
end

View File

@@ -38,43 +38,20 @@ module Sources
end
end
context "The source site for a nijie page" do
setup do
CurrentUser.user = FactoryBot.create(:user)
CurrentUser.ip_addr = "127.0.0.1"
@site = Source::Extractor.find("https://nijie.info/view.php?id=213043")
end
should "get the image url" do
assert_equal(["https://pic.nijie.net/07/nijie/17/95/728995/illust/0_0_403fdd541191110c_c25585.jpg"], @site.image_urls)
assert_downloaded(132_555, @site.image_urls.sole)
end
should "get the page url" do
assert_equal("https://nijie.info/view.php?id=213043", @site.page_url)
end
should "get the profile" do
assert_equal("https://nijie.info/members.php?id=728995", @site.profile_url)
end
should "get the artist name" do
assert_equal("", @site.artist_name)
end
should "get the tags" do
tags = [
["眼鏡", "https://nijie.info/search.php?word=%E7%9C%BC%E9%8F%A1"],
["谷間", "https://nijie.info/search.php?word=%E8%B0%B7%E9%96%93"],
["リトルウィッチアカデミア", "https://nijie.info/search.php?word=%E3%83%AA%E3%83%88%E3%83%AB%E3%82%A6%E3%82%A3%E3%83%83%E3%83%81%E3%82%A2%E3%82%AB%E3%83%87%E3%83%9F%E3%82%A2"],
["アーシュラ先生", "https://nijie.info/search.php?word=%E3%82%A2%E3%83%BC%E3%82%B7%E3%83%A5%E3%83%A9%E5%85%88%E7%94%9F"],
["上着全開", "https://nijie.info/search.php?word=%E4%B8%8A%E7%9D%80%E5%85%A8%E9%96%8B"]
]
assert_equal(tags, @site.tags)
end
context "A Nijie page" do
strategy_should_work(
"https://nijie.info/view.php?id=213043",
image_urls: ["https://pic.nijie.net/07/nijie/17/95/728995/illust/0_0_403fdd541191110c_c25585.jpg"],
download_size: 132_555,
artist_name: "",
profile_url: "https://nijie.info/members.php?id=728995",
artist_commentary_title: "ジャージの下は",
dtext_artist_commentary_desc: "「リトルウィッチアカデミア」から無自覚サキュバスぶりを発揮するアーシュラ先生です",
tags: %w[眼鏡 リトルウィッチアカデミア アーシュラ先生],
)
end
context "A Nijie post" do
should "normalize characters in tags" do
FactoryBot.create(:tag, :name => "kaga")
FactoryBot.create(:wiki_page, :title => "kaga", :other_names => "加賀(艦これ)")
@@ -84,14 +61,6 @@ module Sources
assert_includes(@site.tags.map(&:first), "加賀(艦これ)")
assert_includes(@site.translated_tags.map(&:name), "kaga")
end
should "get the commentary" do
title = "ジャージの下は"
desc = "「リトルウィッチアカデミア」から無自覚サキュバスぶりを発揮するアーシュラ先生です"
assert_equal(title, @site.dtext_artist_commentary_title)
assert_equal(desc, @site.dtext_artist_commentary_desc)
end
end
context "For long commentaries that may be truncated" do

View File

@@ -56,7 +56,7 @@ module Sources
assert_equal(<<~EOS.chomp, source.artist_commentary_desc)
>https://youtu.be/nkjZkEALg94
>https://youtu.be/nkjZkEALg94
( ´ )

View File

@@ -227,6 +227,24 @@ module Sources
end
end
context "A *.media.tumblr.com/$hash/tumblr_$id_$size.png URL with a referer" do
strategy_should_work(
"https://64.media.tumblr.com/3bbfcbf075ddf969c996641b264086fd/tumblr_os2buiIOt51wsfqepo1_400.png",
referer: "https://noizave.tumblr.com/post/162206271767",
image_urls: ["https://media.tumblr.com/3bbfcbf075ddf969c996641b264086fd/tumblr_os2buiIOt51wsfqepo1_1280.png"],
download_size: 3655,
)
end
context "A *.media.tumblr.com/tumblr_$id_$size.jpg URL with a referer" do
strategy_should_work(
"http://media.tumblr.com/tumblr_m24kbxqKAX1rszquso1_250.jpg",
referer: "https://noizave.tumblr.com/post/162206271767",
image_urls: ["https://media.tumblr.com/tumblr_m24kbxqKAX1rszquso1_1280.jpg"],
download_size: 105_963,
)
end
context "generating page urls" do
should "work" do
source1 = "https://octrain1020.tumblr.com/post/190713122589"