]> gitweb.michael.orlitzky.com - dead/whatever-dl.git/blob - test/yikers_test.rb
Added the ability to download videos from http://www.yikers.com/.
[dead/whatever-dl.git] / test / yikers_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/yikers'
21
22 class YikersTest < Test::Unit::TestCase
23
24 def test_owns_yikers_urls
25 assert(Yikers.owns_url?('http://www.yikers.com/video_sexy_drunk_girl_crashes_dirtbike.html'))
26 assert(Yikers.owns_url?('http://www.yikers.com/video_almost_transformers.html'))
27 assert(Yikers.owns_url?('http://yikers.com/video_almost_transformers.html'))
28 assert(Yikers.owns_url?('www.yikers.com/video_noisy_drinking_cat.html'))
29 assert(Yikers.owns_url?('yikers.com/video_college_cafeteria_strip_off.html'))
30 end
31
32
33 def test_doesnt_own_howcast_urls
34 assert(!Yikers.owns_url?('http://www.howcast.com/videos/6807-2twr'))
35 assert(!Yikers.owns_url?('www.howcast.com/videos/6807-2dgfdg'))
36 assert(!Yikers.owns_url?('http://howcast.com/videos/6807-cse'))
37 assert(!Yikers.owns_url?('howcast.com/videos/6807-asdgasd'))
38 end
39
40
41 def test_doesnt_own_redtube_urls
42 assert(!Yikers.owns_url?('http://www.redtube.com/6807'))
43 assert(!Yikers.owns_url?('www.redtube.com/6807'))
44 assert(!Yikers.owns_url?('http://redtube.com/6807'))
45 assert(!Yikers.owns_url?('redtube.com/6807'))
46 end
47
48 def test_doesnt_own_misc_urls
49 assert(!Yikers.owns_url?('http://www.howcast.com/abc'))
50 end
51
52
53 def test_parse_xml_path
54 yikers = Yikers.new(nil)
55
56 page_data = nil
57
58 File.open('test/fixtures/yikers/video_college_cafeteria_strip_off.html') do |f|
59 page_data = f.read
60 end
61
62 test_result = yikers.send('parse_xml_path', page_data)
63 assert_equal('/flash/play_flash_xml.php?cid=11798', test_result)
64 end
65
66
67 def test_parse_video_url
68 yikers = Yikers.new(nil)
69
70 page_data = nil
71
72 File.open('test/fixtures/yikers/video_college_cafeteria_strip_off.xml') do |f|
73 page_data = f.read
74 end
75
76 test_result = yikers.send('parse_video_url', page_data)
77 assert_equal('http://cdn.yikers.com/flv/flash8/yikers_college_cafeteria_strip_off.flv', test_result)
78 end
79
80
81 def test_get_video_filename
82 yikers = Yikers.new('http://www.yikers.com/video_college_cafeteria_strip_off.html')
83 assert_equal('video_college_cafeteria_strip_off.flv', yikers.get_video_filename())
84 end
85
86
87 def test_uri_query_works_on_yikers_urls
88 uri = URI.parse('http://www.yikers.com/flash/play_flash_xml.php?cid=11798')
89 http_path = uri.path + '?' + uri.query
90 assert_equal('/flash/play_flash_xml.php?cid=11798', http_path)
91 end
92
93 end