tests: fix nicoseiga download tests.

This commit is contained in:
evazion
2020-06-16 00:04:31 -05:00
parent 7868e5045e
commit b583b3c810
2 changed files with 27 additions and 32 deletions

View File

@@ -1,32 +0,0 @@
require "test_helper"
module Downloads
class NicoSeigaTest < ActiveSupport::TestCase
context "downloading a 'http://seiga.nicovideo.jp/seiga/:id' url" do
should "download the original file" do
@source = "http://seiga.nicovideo.jp/seiga/im4937663"
@rewrite = %r!http://lohas.nicoseiga.jp/priv/\h{40}/\d+/4937663!
assert_rewritten(@rewrite, @source)
assert_downloaded(2032, @source)
end
end
context "downloading a 'http://lohas.nicoseiga.jp/o/:hash/:id' url" do
should "download the original file" do
@source = "http://lohas.nicoseiga.jp/o/910aecf08e542285862954017f8a33a8c32a8aec/1433298801/4937663"
@rewrite = %r!http://lohas.nicoseiga.jp/priv/\h{40}/\d+/4937663!
assert_rewritten(@rewrite, @source)
assert_downloaded(2032, @source)
end
end
context "downloading a 'https://lohas.nicoseiga.jp/thumb/:id' url" do
should "download the original file" do
@source = "https://lohas.nicoseiga.jp/thumb/4937663i"
@rewrite = %r!http://lohas.nicoseiga.jp/priv/\h{40}/\d+/4937663!
assert_rewritten(@rewrite, @source)
assert_downloaded(2032, @source)
end
end
end
end

View File

@@ -147,5 +147,32 @@ module Sources
assert_equal(bad_source, Sources::Strategies.normalize_source(bad_source))
end
end
context "downloading a 'http://seiga.nicovideo.jp/seiga/:id' url" do
should "download the original file" do
@source = "http://seiga.nicovideo.jp/seiga/im4937663"
@rewrite = %r{https://lohas.nicoseiga.jp/priv/\h{40}/\d+/4937663}
assert_rewritten(@rewrite, @source)
assert_downloaded(2_032, @source)
end
end
context "downloading a 'http://lohas.nicoseiga.jp/o/:hash/:id' url" do
should "download the original file" do
@source = "http://lohas.nicoseiga.jp/o/910aecf08e542285862954017f8a33a8c32a8aec/1433298801/4937663"
@rewrite = %r{https://lohas.nicoseiga.jp/priv/\h{40}/\d+/4937663}
assert_rewritten(@rewrite, @source)
assert_downloaded(2_032, @source)
end
end
context "downloading a 'https://lohas.nicoseiga.jp/thumb/:id' url" do
should "download the original file" do
@source = "https://lohas.nicoseiga.jp/thumb/4937663i"
@rewrite = %r{https://lohas.nicoseiga.jp/priv/\h{40}/\d+/4937663}
assert_rewritten(@rewrite, @source)
assert_downloaded(2_032, @source)
end
end
end
end