require 'test_helper' module Sources class DeviantArtTest < ActiveSupport::TestCase def setup super skip "DeviantArt API keys not set" unless Danbooru.config.deviantart_client_id.present? end context "The source for a private DeviantArt image URL" do setup do @site = Sources::Site.new("https://pre00.deviantart.net/423b/th/pre/i/2017/281/e/0/mindflayer_girl01_by_nickbeja-dbpxdt8.png") @site.get end should "work" do assert_equal(["https://pre00.deviantart.net/423b/th/pre/i/2017/281/e/0/mindflayer_girl01_by_nickbeja-dbpxdt8.png"], @site.image_urls) end end context "The source for a download-disabled DeviantArt artwork page" do should "get the image url" do @site = Sources::Site.new("https://noizave.deviantart.com/art/test-no-download-697415967") assert_equal(["https://img00.deviantart.net/56ee/i/2017/219/2/3/test__no_download_by_noizave-dbj81lr.jpg"], @site.image_urls) end end context "The source for a DeviantArt image url" do should "fetch the source data" do @site = Sources::Site.new("https://pre00.deviantart.net/b5e6/th/pre/f/2016/265/3/5/legend_of_galactic_heroes_by_hideyoshi-daihpha.jpg") assert_equal("hideyoshi", @site.artist_name) assert_equal("https://hideyoshi.deviantart.com", @site.profile_url) assert_equal("https://orig00.deviantart.net/9e1f/f/2016/265/3/5/legend_of_galactic_heroes_by_hideyoshi-daihpha.jpg", @site.image_url) end end context "The source for an DeviantArt artwork page" do setup do @site = Sources::Site.new("http://noizave.deviantart.com/art/test-post-please-ignore-685436408") @site.get end should "get the image url" do assert_match(%r!https?://origin-orig.deviantart.net/7b5b/f/2017/160/c/5/test_post_please_ignore_by_noizave-dbc3a48.png!, @site.image_url) end should "get the profile" do assert_equal("https://noizave.deviantart.com", @site.profile_url) end should "get the artist name" do assert_equal("noizave", @site.artist_name) end should "get the tags" do assert_equal(%w[bar baz foo], @site.tags.map(&:first)) end should "get the artist commentary" do title = "test post please ignore" desc = "
this is a quote