* Test that downloading the HTML page downloads the full size image instead. * Test that downloading a small or medium size image downloads the full size instead. * Test the above for both single illustrations and for manga galleries, for new and old posts (i.e. uploaded before the Pixiv URL changes versus after), and for different file extensions. * Test trying to download ugoira zip files. These tests are expected to fail because we don't support ugoira yet. * Also add some more tests for fetching source data.
102 lines
2.9 KiB
Ruby
102 lines
2.9 KiB
Ruby
# encoding: UTF-8
|
|
|
|
require 'test_helper'
|
|
|
|
module Sources
|
|
class PixivTest < ActiveSupport::TestCase
|
|
def get_source(source, cassette)
|
|
VCR.use_cassette(cassette, :record => :once) do
|
|
@site = Sources::Site.new(source)
|
|
@site.get
|
|
@site
|
|
end
|
|
end
|
|
|
|
context "fetching source data for a new manga image" do
|
|
setup do
|
|
get_source("http://www.pixiv.net/member_illust.php?mode=medium&illust_id=46324488", "source-pixiv-new-manga")
|
|
end
|
|
|
|
should "get the profile" do
|
|
assert_equal("http://www.pixiv.net/member.php?id=339253", @site.profile_url)
|
|
end
|
|
|
|
should "get the artist name" do
|
|
assert_equal("evazion", @site.artist_name)
|
|
end
|
|
|
|
should "get the full size image url" do
|
|
assert_equal("http://i1.pixiv.net/img-original/img/2014/10/03/18/10/20/46324488_p0.png", @site.image_url)
|
|
end
|
|
|
|
should "get the page count" do
|
|
assert_equal(3, @site.page_count)
|
|
end
|
|
|
|
should "get the tags" do
|
|
pixiv_tags = @site.tags.map(&:first)
|
|
pixiv_links = @site.tags.map(&:last)
|
|
|
|
assert_equal(%w(R-18G derp tag1 tag2 オリジナル), pixiv_tags)
|
|
assert_contains(pixiv_links, /search\.php/)
|
|
end
|
|
|
|
should "convert a page into a json representation" do
|
|
assert_nothing_raised do
|
|
@site.to_json
|
|
end
|
|
end
|
|
end
|
|
|
|
context "fetching source data for an old manga image" do
|
|
setup do
|
|
get_source("http://www.pixiv.net/member_illust.php?mode=medium&illust_id=45792845", "source-pixiv-old-manga")
|
|
end
|
|
|
|
should "get the page count" do
|
|
assert_equal(3, @site.page_count)
|
|
end
|
|
|
|
should "get the full size image url" do
|
|
assert_equal("http://i2.pixiv.net/img18/img/ringo78/45792845_big_p0.jpg", @site.image_url)
|
|
end
|
|
end
|
|
|
|
context "fetching source data for a new illustration" do
|
|
setup do
|
|
get_source("http://www.pixiv.net/member_illust.php?mode=medium&illust_id=46337015", "source-pixiv-new-illust")
|
|
end
|
|
|
|
should "get the page count" do
|
|
assert_equal(1, @site.page_count)
|
|
end
|
|
|
|
should "get the full size image url" do
|
|
assert_equal("http://i2.pixiv.net/img-original/img/2014/10/04/03/59/52/46337015_p0.png", @site.image_url)
|
|
end
|
|
end
|
|
|
|
context "fetching source data for an old illustration" do
|
|
setup do
|
|
get_source("http://www.pixiv.net/member_illust.php?mode=medium&illust_id=14901720", "source-pixiv-old-illust")
|
|
end
|
|
|
|
should "get the page count" do
|
|
assert_equal(1, @site.page_count)
|
|
end
|
|
|
|
should "get the full size image url" do
|
|
assert_equal("http://i2.pixiv.net/img18/img/evazion/14901720.png", @site.image_url)
|
|
end
|
|
|
|
should "get the tags" do
|
|
pixiv_tags = @site.tags.map(&:first)
|
|
pixiv_links = @site.tags.map(&:last)
|
|
|
|
assert_equal(%w(derp), pixiv_tags)
|
|
assert_contains(pixiv_links, /search\.php/)
|
|
end
|
|
end
|
|
end
|
|
end
|