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/efukt'
23 class EfuktTest
< Test
::Unit::TestCase
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'))
30 def test_doesnt_own_infoq_urls
31 assert(!Efukt
.owns_url
?('http://www.infoq.com/interviews/jim-weirich-discusses-rake'))
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
)
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
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
)
56 def test_parse_video_url
61 File
.open('test/fixtures/efukt/2304_The_Dumbest_Porno_Ever_Made.html') do |f
|
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
)
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
72 File
.open('test/fixtures/efukt/1592_Riding_Bear_Back.html') do |f
|
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
)