]> gitweb.michael.orlitzky.com - dead/whatever-dl.git/blob - test/megaporn_test.rb
Whitespace cleanup.
[dead/whatever-dl.git] / test / megaporn_test.rb
1 #
2 # Copyright Michael Orlitzky
3 #
4 # http://michael.orlitzky.com/
5 #
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.
10 #
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.
15 #
16 # http://www.fsf.org/licensing/licenses/gpl.html
17 #
18
19 require 'test/unit'
20 require 'whatever-dl/websites/megaporn'
21
22
23 class MegapornTest < Test::Unit::TestCase
24
25 def test_owns_megaporn_urls
26 assert(Megaporn.owns_url?('http://www.megaporn.com/video/?v=E1LROW6E'))
27 end
28
29
30 def test_doesnt_own_infoq_urls
31 assert(!Megaporn.owns_url?('http://www.infoq.com/interviews/jim-weirich-discusses-rake'))
32 end
33
34
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'))
40 end
41
42
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'))
46 end
47
48
49 def test_parse_flash_variable
50 mp = Megaporn.new(nil)
51 page_data = nil
52
53 File.open('test/fixtures/megaporn/E1LROW6E.html') do |f|
54 page_data = f.read
55 end
56
57 # Seed
58 expected_result = '71eef99c126511b92b770d654ecd25c8'
59 actual_result = mp.send('parse_flash_variable', page_data, 'un')
60 assert_equal(expected_result, actual_result)
61
62 # key1
63 expected_result = '63233'
64 actual_result = mp.send('parse_flash_variable', page_data, 'k1')
65 assert_equal(expected_result, actual_result)
66
67 # key2
68 expected_result = '185149'
69 actual_result = mp.send('parse_flash_variable', page_data, 'k2')
70 assert_equal(expected_result, actual_result)
71
72 # Host suffix
73 expected_result = '118'
74 actual_result = mp.send('parse_flash_variable', page_data, 's')
75 assert_equal(expected_result, actual_result)
76 end
77
78 end