]> gitweb.michael.orlitzky.com - dead/whatever-dl.git/blob - test/vimeo_test.rb
Made the output filename the responsibility of the website subclass.
[dead/whatever-dl.git] / test / vimeo_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/vimeo'
21
22 # There are no remote tests for Vimeo because they use
23 # an expiration timestamp to change certain values in the
24 # URL. Obviously, these tests wouldn't pass after the
25 # timestamp expired.
26 class VimeoTest < Test::Unit::TestCase
27
28 def test_parse_standard_video_id
29 v = Vimeo.new('http://www.vimeo.com/1561578')
30
31 # First form, with the id at the end.
32 video_id = v.send('parse_video_id')
33 assert_equal('1561578', video_id)
34 end
35
36
37 def test_parse_swf_video_id
38 v = Vimeo.new('http://www.vimeo.com/moogaloop.swf?clip_id=1561578&server=www.vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1')
39
40 # Second, clip_id= form.
41 video_id = v.send('parse_video_id')
42 assert_equal('1561578', video_id)
43 end
44
45
46 def test_parse_request_signature
47 v = Vimeo.new(nil)
48
49 details_data = nil
50
51 File.open('test/fixtures/vimeo/details_data-1561578.xml') do |f|
52 details_data = f.read
53 end
54
55 actual_result = v.send('parse_request_signature', details_data)
56 expected_result = 'db66311d431bedb4ba997a7b1d1946e2'
57
58 assert_equal(expected_result, actual_result)
59 end
60
61
62 def test_parse_request_signature_expires
63 v = Vimeo.new(nil)
64
65 details_data = nil
66
67 File.open('test/fixtures/vimeo/details_data-1561578.xml') do |f|
68 details_data = f.read
69 end
70
71 actual_result = v.send('parse_request_signature_expires', details_data)
72 expected_result = '1220068800'
73
74 assert_equal(expected_result, actual_result)
75 end
76
77
78 def test_parse_quality
79 v = Vimeo.new(nil)
80
81 details_data = nil
82
83 File.open('test/fixtures/vimeo/details_data-1561578.xml') do |f|
84 details_data = f.read
85 end
86
87 actual_result = v.send('parse_quality', details_data)
88 expected_result = 'sd'
89
90 assert_equal(expected_result, actual_result)
91 end
92
93
94 def test_owns_standard_vimeo_url
95 assert(Vimeo.owns_url?('http://www.vimeo.com/1561578'))
96 end
97
98
99 def test_owns_swf_video_url
100 assert(Vimeo.owns_url?('http://www.vimeo.com/moogaloop.swf?clip_id=1561578&server=www.vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1'))
101 end
102
103
104 def test_doesnt_own_howcast_urls
105 assert(!Vimeo.owns_url?('http://www.howcast.com/videos/6807-2twr'))
106 assert(!Vimeo.owns_url?('www.howcast.com/videos/6807-2dgfdg'))
107 assert(!Vimeo.owns_url?('http://howcast.com/videos/6807-cse'))
108 assert(!Vimeo.owns_url?('howcast.com/videos/6807-asdgasd'))
109 end
110
111
112 def test_doesnt_own_redtube_urls
113 assert(!Vimeo.owns_url?('http://www.redtube.com/6807'))
114 assert(!Vimeo.owns_url?('www.redtube.com/6807'))
115 assert(!Vimeo.owns_url?('http://redtube.com/6807'))
116 assert(!Vimeo.owns_url?('redtube.com/6807'))
117 end
118
119 def test_doesnt_own_misc_urls
120 assert(!Vimeo.owns_url?('http://www.howcast.com/abc'))
121 end
122
123 end