]> gitweb.michael.orlitzky.com - dead/whatever-dl.git/blob - test/howcast_test.rb
aacfcf2d65b670299d66a66188a3a2e4cf2ae868
[dead/whatever-dl.git] / test / howcast_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/howcast'
21
22 # Unit tests for the Howcast class.
23 # This class is easy because get_video_url is
24 # just a string interpolation (we don't have to
25 # test that).
26
27 class HowcastTest < Test::Unit::TestCase
28
29 def test_owns_howcast_urls
30
31 assert(Howcast.owns_url?('http://www.howcast.com/videos/6807-2twr'))
32 assert(Howcast.owns_url?('www.howcast.com/videos/6807-2dgfdg'))
33 assert(Howcast.owns_url?('http://howcast.com/videos/6807-cse'))
34 assert(Howcast.owns_url?('howcast.com/videos/6807-asdgasd'))
35 end
36
37
38 def test_doesnt_own_redtube_urls
39 assert(!Howcast.owns_url?('http://www.redtube.com/6807'))
40 assert(!Howcast.owns_url?('www.redtube.com/6807'))
41 assert(!Howcast.owns_url?('http://redtube.com/6807'))
42 assert(!Howcast.owns_url?('redtube.com/6807'))
43 end
44
45
46 def test_doesnt_own_misc_urls
47 assert(!Howcast.owns_url?('http://www.howcast.com/abc'))
48 end
49
50
51 def test_parse_file_path_from_xml
52 hc = Howcast.new(nil)
53
54 page_data = nil
55
56 File.open('test/fixtures/howcast/81134.xml') do |f|
57 page_data = f.read
58 end
59
60 test_result = hc.send('parse_file_path_from_xml', page_data)
61 assert_equal('/system/videos/4/34/11/08/81134.flv', test_result)
62 end
63
64 end