2 # Copyright Michael Orlitzky
4 # http://michael.orlitzky.com/
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # http://www.fsf.org/licensing/licenses/gpl.html
20 require 'src/websites/megaporn'
23 class MegapornTest
< Test
::Unit::TestCase
25 def test_owns_megaporn_urls
26 assert(Megaporn
.owns_url
?('http://www.megaporn.com/video/?v=E1LROW6E'))
30 def test_doesnt_own_infoq_urls
31 assert(!Megaporn
.owns_url
?('http://www.infoq.com/interviews/jim-weirich-discusses-rake'))
35 def test_doesnt_own_redtube_urls
36 assert(!Megaporn
.owns_url
?('http://www.redtube.com/6807'))
37 assert(!Megaporn
.owns_url
?('www.redtube.com/6807'))
38 assert(!Megaporn
.owns_url
?('http://redtube.com/6807'))
39 assert(!Megaporn
.owns_url
?('redtube.com/6807'))
43 def test_doesnt_own_efukt_urls
44 assert(!Megaporn
.owns_url
?('http://www.efukt.com/2308_How_To_Fuck_Like_A_King.html'))
45 assert(!Megaporn
.owns_url
?('http://www.efukt.com/2304_The_Dumbest_Porno_Ever_Made.html'))
50 mp
= Megaporn
.new(nil)
51 expected_result
= '3de0ae51c90c7b100cc41e899648ac3c'
52 actual_result
= mp
.send('decrypt', 'becc1abe04b5ab8cb10dc7d29a497958', '49298', '63031')
53 assert_equal(expected_result
, actual_result
)
57 def test_parse_flash_variable
58 mp
= Megaporn
.new(nil)
61 File
.open('test/fixtures/megaporn/E1LROW6E.html') do |f
|
66 expected_result
= '71eef99c126511b92b770d654ecd25c8'
67 actual_result
= mp
.send('parse_flash_variable', page_data
, 'un')
68 assert_equal(expected_result
, actual_result
)
71 expected_result
= '63233'
72 actual_result
= mp
.send('parse_flash_variable', page_data
, 'k1')
73 assert_equal(expected_result
, actual_result
)
76 expected_result
= '185149'
77 actual_result
= mp
.send('parse_flash_variable', page_data
, 'k2')
78 assert_equal(expected_result
, actual_result
)
81 expected_result
= '118'
82 actual_result
= mp
.send('parse_flash_variable', page_data
, 's')
83 assert_equal(expected_result
, actual_result
)