# # 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 'whatever-dl/websites/megaporn' class MegapornTest < Test::Unit::TestCase def test_owns_megaporn_urls assert(Megaporn.owns_url?('http://www.megaporn.com/video/?v=E1LROW6E')) end def test_doesnt_own_infoq_urls assert(!Megaporn.owns_url?('http://www.infoq.com/interviews/jim-weirich-discusses-rake')) end def test_doesnt_own_redtube_urls assert(!Megaporn.owns_url?('http://www.redtube.com/6807')) assert(!Megaporn.owns_url?('www.redtube.com/6807')) assert(!Megaporn.owns_url?('http://redtube.com/6807')) assert(!Megaporn.owns_url?('redtube.com/6807')) end def test_doesnt_own_efukt_urls assert(!Megaporn.owns_url?('http://www.efukt.com/2308_How_To_Fuck_Like_A_King.html')) assert(!Megaporn.owns_url?('http://www.efukt.com/2304_The_Dumbest_Porno_Ever_Made.html')) end def test_parse_flash_variable mp = Megaporn.new(nil) page_data = nil File.open('test/fixtures/megaporn/E1LROW6E.html') do |f| page_data = f.read end # Seed expected_result = '71eef99c126511b92b770d654ecd25c8' actual_result = mp.send('parse_flash_variable', page_data, 'un') assert_equal(expected_result, actual_result) # key1 expected_result = '63233' actual_result = mp.send('parse_flash_variable', page_data, 'k1') assert_equal(expected_result, actual_result) # key2 expected_result = '185149' actual_result = mp.send('parse_flash_variable', page_data, 'k2') assert_equal(expected_result, actual_result) # Host suffix expected_result = '118' actual_result = mp.send('parse_flash_variable', page_data, 's') assert_equal(expected_result, actual_result) end end