]> gitweb.michael.orlitzky.com - dead/whatever-dl.git/blob - test/efukt_test.rb
Added GetOpt option parsing.
[dead/whatever-dl.git] / test / efukt_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 'src/websites/efukt'
21
22
23 class EfuktTest < Test::Unit::TestCase
24
25 def test_owns_efukt_urls
26 assert(Efukt.owns_url?('http://www.efukt.com/2308_How_To_Fuck_Like_A_King.html'))
27 assert(Efukt.owns_url?('http://www.efukt.com/2304_The_Dumbest_Porno_Ever_Made.html'))
28 end
29
30 def test_doesnt_own_infoq_urls
31 assert(!Efukt.owns_url?('http://www.infoq.com/interviews/jim-weirich-discusses-rake'))
32 end
33
34
35 def test_get_video_filename_works_on_good_urls
36 ef = Efukt.new('http://www.efukt.com/2308_How_To_Fuck_Like_A_King.html')
37 expected_filename = '2308_How_To_Fuck_Like_A_King.flv'
38 actual_filename = ef.get_video_filename()
39 assert_equal(expected_filename, actual_filename)
40 end
41
42
43 def test_get_video_filename_works_on_weird_urls
44 # The regex looks for an html extension, so this should
45 # not match. Instead, it should fall back on everything
46 # between the final slash and that last period. In this
47 # case, the filename should be the same as if the extension
48 # were html.
49 ef = Efukt.new('http://www.efukt.com/2308_How_To_Fuck_Like_A_King.broken')
50 expected_filename = '2308_How_To_Fuck_Like_A_King.flv'
51 actual_filename = ef.get_video_filename()
52 assert_equal(expected_filename, actual_filename)
53 end
54
55
56 def test_parse_video_url
57 ef = Efukt.new(nil)
58
59 page_data = nil
60
61 File.open('test/fixtures/efukt/2304_The_Dumbest_Porno_Ever_Made.html') do |f|
62 page_data = f.read
63 end
64
65 test_result = ef.send('parse_video_url', page_data)
66 assert_equal('http://64.62.222.195/video/370c4a4662071261ccd5b833c4d83201/4918d88d/63563562.flv', test_result)
67
68 # There are two different filename patterns.
69 # This tests the second one. No, there aren't
70 # any non-embarrasing videos on eFukt that I could
71 # use for fixtures.
72 File.open('test/fixtures/efukt/1592_Riding_Bear_Back.html') do |f|
73 page_data = f.read
74 end
75
76 test_result = ef.send('parse_video_url', page_data)
77 assert_equal('http://74.82.53.202/video/798309ad4e6b598204aae617bbdf3090/4a99e23f/158.wmv', test_result)
78 end
79
80 end