X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=test%2Fefukt_test.rb;fp=test%2Fefukt_test.rb;h=33b1bf2cca0a73b98d6458cc24be4a25905ce7db;hb=5359bc2a58320794c5d6d91acb39eac4f371c9c2;hp=0000000000000000000000000000000000000000;hpb=1d43361a1d8c6fc3938a2438baa8d8348129b4fd;p=dead%2Fwhatever-dl.git diff --git a/test/efukt_test.rb b/test/efukt_test.rb new file mode 100644 index 0000000..33b1bf2 --- /dev/null +++ b/test/efukt_test.rb @@ -0,0 +1,69 @@ +# +# Copyright Michael Orlitzky +# +# http://michael.orlitzky.com/ +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# http://www.fsf.org/licensing/licenses/gpl.html +# + +require 'test/unit' +require 'src/websites/efukt' + + +class EfuktTest < Test::Unit::TestCase + + def test_owns_efukt_urls + assert(Efukt.owns_url?('http://www.efukt.com/2308_How_To_Fuck_Like_A_King.html')) + assert(Efukt.owns_url?('http://www.efukt.com/2304_The_Dumbest_Porno_Ever_Made.html')) + end + + def test_doesnt_own_infoq_urls + assert(!Efukt.owns_url?('http://www.infoq.com/interviews/jim-weirich-discusses-rake')) + end + + + def test_get_video_filename_works_on_good_urls + ef = Efukt.new('http://www.efukt.com/2308_How_To_Fuck_Like_A_King.html') + expected_filename = '2308_How_To_Fuck_Like_A_King.flv' + actual_filename = ef.get_video_filename() + assert_equal(expected_filename, actual_filename) + end + + + def test_get_video_filename_works_on_weird_urls + # The regex looks for an html extension, so this should + # not match. Instead, it should fall back on everything + # between the final slash and that last period. In this + # case, the filename should be the same as if the extension + # were html. + ef = Efukt.new('http://www.efukt.com/2308_How_To_Fuck_Like_A_King.broken') + expected_filename = '2308_How_To_Fuck_Like_A_King.flv' + actual_filename = ef.get_video_filename() + assert_equal(expected_filename, actual_filename) + end + + + def test_parse_video_url + ef = Efukt.new(nil) + + page_data = nil + + File.open('test/fixtures/efukt/2304_The_Dumbest_Porno_Ever_Made.html') do |f| + page_data = f.read + end + + test_result = ef.send('parse_video_url', page_data) + assert_equal('http://64.62.222.195/video/370c4a4662071261ccd5b833c4d83201/4918d88d/63563562.flv', test_result) + end + +end