]> gitweb.michael.orlitzky.com - dead/whatever-dl.git/blob - test/veoh_test.rb
Added new tests for (yet another) Veoh URL format.
[dead/whatever-dl.git] / test / veoh_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/veoh'
21
22 class VeohTest < Test::Unit::TestCase
23
24 def test_parse_video_id
25 v = Veoh.new('http://www.veoh.com/videos/v801204yMZ8BWcC')
26 video_id = v.send('parse_video_id')
27 assert_equal('v801204yMZ8BWcC', video_id)
28 end
29
30
31 def test_parse_second_video_id
32 v = Veoh.new('http://www.veoh.com/videos/v15795090Z6mZAbSq')
33 video_id = v.send('parse_video_id')
34 assert_equal('v15795090Z6mZAbSq', video_id)
35 end
36
37
38 def test_parse_third_video_id
39 v = Veoh.new('http://www.veoh.com/group/suggested-anime-w1st-episodes/?source=homepageList#watch%3Dv19961527w773Qq5G')
40 video_id = v.send('parse_video_id')
41 assert_equal('v19961527w773Qq5G', video_id)
42 end
43
44
45 def test_parse_fourth_video_id
46 v = Veoh.new('http://www.veoh.com/browse/videos/category/anime/watch/v19568793XZq2SRzZ')
47 video_id = v.send('parse_video_id')
48 assert_equal('v19568793XZq2SRzZ', video_id)
49 end
50
51
52 def test_parse_fifth_video_id
53 v = Veoh.new('http://www.veoh.com/collection/Keith-Anderson-Music-Videos/watch/v13890200h98YShYN')
54 video_id = v.send('parse_video_id')
55 assert_equal('v13890200h98YShYN', video_id)
56 end
57
58
59 def test_parse_redirect_url
60 v = Veoh.new(nil)
61
62 details_data = nil
63
64 File.open('test/fixtures/veoh/details_data-v801204yMZ8BWcC.xml') do |f|
65 details_data = f.read
66 end
67
68 actual_result = v.send('parse_redirect_url', details_data)
69 expected_result = 'http://content.veoh.com/flash/p/801204/7b55b0e3fef09c5599ba2ab3d6a270c3dc9c0a0d.flv?ct=8c18f78c97a2df5cb5f7d849dce97c28996b0835dfc71ce9'
70
71 assert_equal(expected_result, actual_result)
72 end
73
74
75 def test_second_parse_redirect_url
76 v = Veoh.new(nil)
77
78 details_data = nil
79
80 File.open('test/fixtures/veoh/details_data-v15795090Z6mZAbSq.xml') do |f|
81 details_data = f.read
82 end
83
84 actual_result = v.send('parse_redirect_url', details_data)
85 expected_result = 'http://content.veoh.com/flash/f/2/v15795090Z6mZAbSq/3f8044ce2538155c55af5c036cd96ba82a83ddb5.flv?ct=ff4914d2e699e8ad04a69102faaab6ce82b7704998890f69'
86
87 assert_equal(expected_result, actual_result)
88 end
89
90
91
92 def test_owns_veoh_urls
93 assert(Veoh.owns_url?('http://www.veoh.com/videos/v801204yMZ8BWcC'))
94 assert(Veoh.owns_url?('http://www.veoh.com/videos/v15795090Z6mZAbSq'))
95 assert(Veoh.owns_url?('http://www.veoh.com/group/suggested-anime-w1st-episodes/?source=homepageList#watch%3Dv19961527w773Qq5G'))
96 assert(Veoh.owns_url?('http://www.veoh.com/browse/videos/category/anime/watch/v19568793XZq2SRzZ'))
97 assert(Veoh.owns_url?('http://www.veoh.com/collection/Keith-Anderson-Music-Videos/watch/v13890200h98YShYN'))
98 end
99
100 end