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/vimeo'
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
26 class VimeoTest
< Test
::Unit::TestCase
28 def test_parse_standard_video_id
31 # First form, with the id at the end.
32 video_id
= v
.send('parse_video_id', 'http://www.vimeo.com/1561578')
33 assert_equal('1561578', video_id
)
37 def test_parse_swf_video_id
40 # Second, clip_id= form.
41 video_id
= v
.send('parse_video_id', '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')
42 assert_equal('1561578', video_id
)
46 def test_parse_request_signature
51 File
.open('test/fixtures/vimeo/details_data-1561578.xml') do |f
|
55 actual_result
= v
.send('parse_request_signature', details_data
)
56 expected_result
= 'db66311d431bedb4ba997a7b1d1946e2'
58 assert_equal(expected_result
, actual_result
)
62 def test_parse_request_signature_expires
67 File
.open('test/fixtures/vimeo/details_data-1561578.xml') do |f
|
71 actual_result
= v
.send('parse_request_signature_expires', details_data
)
72 expected_result
= '1220068800'
74 assert_equal(expected_result
, actual_result
)
78 def test_parse_quality
83 File
.open('test/fixtures/vimeo/details_data-1561578.xml') do |f
|
87 actual_result
= v
.send('parse_quality', details_data
)
88 expected_result
= 'sd'
90 assert_equal(expected_result
, actual_result
)
94 def test_owns_standard_vimeo_url
95 assert(Vimeo
.owns_url
?('http://www.vimeo.com/1561578'))
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'))
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'))
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'))
119 def test_doesnt_own_misc_urls
120 assert(!Vimeo
.owns_url
?('http://www.howcast.com/abc'))