Files
danbooru/test/unit/sources/pixiv_sketch_test.rb
2022-10-21 11:09:10 +02:00

140 lines
6.7 KiB
Ruby
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
require 'test_helper'
module Sources
class PixivSketchTest < ActiveSupport::TestCase
context "A Pixiv Sketch post" do
strategy_should_work(
"https://sketch.pixiv.net/items/5835314698645024323",
image_urls: ["https://img-sketch.pixiv.net/uploads/medium/file/9986983/8431631593768139653.jpg"],
page_url: "https://sketch.pixiv.net/items/5835314698645024323",
profile_urls: ["https://sketch.pixiv.net/@user_ejkv8372", "https://www.pixiv.net/users/44772126"],
profile_url: "https://sketch.pixiv.net/@user_ejkv8372",
artist_name: "user_ejkv8372",
other_names: ["user_ejkv8372", "サコ"],
artist_commentary_desc: "🍻シャンクスとミホーク誕生日おめでとう🍻(過去絵) ",
tags: []
)
end
context "A Pixiv Sketch image with referer" do
strategy_should_work(
"https://img-sketch.pixiv.net/uploads/medium/file/9986983/8431631593768139653.jpg",
referer: "https://sketch.pixiv.net/items/5835314698645024323",
image_urls: ["https://img-sketch.pixiv.net/uploads/medium/file/9986983/8431631593768139653.jpg"],
page_url: "https://sketch.pixiv.net/items/5835314698645024323",
profile_urls: ["https://sketch.pixiv.net/@user_ejkv8372", "https://www.pixiv.net/users/44772126"],
profile_url: "https://sketch.pixiv.net/@user_ejkv8372",
artist_name: "user_ejkv8372",
other_names: ["user_ejkv8372", "サコ"],
artist_commentary_desc: "🍻シャンクスとミホーク誕生日おめでとう🍻(過去絵) ",
tags: []
)
end
context "A Pixiv Sketch image without the referer" do
# page: https://sketch.pixiv.net/items/8052785510155853613
strategy_should_work(
"https://img-sketch.pixiv.net/uploads/medium/file/9988973/7216948861306830496.jpg",
page_url: nil,
profile_url: nil,
artist_name: nil,
tags: [],
artist_commentary_desc: nil
)
end
context "A NSFW post" do
strategy_should_work(
"https://sketch.pixiv.net/items/193462611994864256",
image_urls: ["https://img-sketch.pixiv.net/uploads/medium/file/884876/4909517173982299587.jpg"],
page_url: "https://sketch.pixiv.net/items/193462611994864256",
profile_url: "https://sketch.pixiv.net/@lithla",
artist_name: "lithla",
other_names: ["lithla", "リリスラウダ"],
artist_commentary_desc: "チビッコ露出プレイ ピース",
tags: []
)
end
context "A post with multiple images" do
desc = <<~EOS.normalize_whitespace
33
()
()
()+
1()
1()()
()
()
5(30)
(3D化できない)
12
()
#制作過程
#このすば
#この素晴らしい世界に祝福を!
#セナ
#バニー
#3月3日
#巨乳
#黒髪巨乳
#タイツ
EOS
strategy_should_work(
"https://sketch.pixiv.net/items/8052785510155853613",
image_urls: %w[
https://img-sketch.pixiv.net/uploads/medium/file/9988964/1564052114639195387.png
https://img-sketch.pixiv.net/uploads/medium/file/9988965/3187185972065199018.png
https://img-sketch.pixiv.net/uploads/medium/file/9988966/5281789458380074490.png
https://img-sketch.pixiv.net/uploads/medium/file/9988967/8187710652175488805.png
https://img-sketch.pixiv.net/uploads/medium/file/9988968/3497441770651131427.png
https://img-sketch.pixiv.net/uploads/medium/file/9988969/1770110164450415039.png
https://img-sketch.pixiv.net/uploads/medium/file/9988970/1340350233137289970.png
https://img-sketch.pixiv.net/uploads/medium/file/9988971/9105451079763734305.jpg
https://img-sketch.pixiv.net/uploads/medium/file/9988972/2641925439408057307.jpg
https://img-sketch.pixiv.net/uploads/medium/file/9988973/7216948861306830496.jpg
],
artist_commentary_desc: desc,
artist_name: "op-one",
page_url: "https://sketch.pixiv.net/items/8052785510155853613",
profile_url: "https://sketch.pixiv.net/@op-one",
tags: %w[制作過程 このすば この素晴らしい世界に祝福を セナ バニー 3月3日 巨乳 黒髪巨乳 タイツ]
)
end
should "Parse Pixiv Sketch URLs correctly" do
assert(Source::URL.image_url?("https://img-sketch.pixiv.net/uploads/medium/file/4463372/8906921629213362989.jpg "))
assert(Source::URL.image_url?("https://img-sketch.pximg.net/c!/w=540,f=webp:jpeg/uploads/medium/file/4463372/8906921629213362989.jpg"))
assert(Source::URL.image_url?("https://img-sketch.pixiv.net/c/f_540/uploads/medium/file/9986983/8431631593768139653.jpg"))
assert(Source::URL.page_url?("https://sketch.pixiv.net/items/5835314698645024323"))
assert(Source::URL.profile_url?("https://sketch.pixiv.net/@user_ejkv8372"))
end
end
end