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/youtube'
22 class YoutubeTest
< Test
::Unit::TestCase
24 def test_owns_youtube_urls
25 assert(Youtube
.owns_url
?('http://www.youtube.com/watch?v=SudixyugiX4'))
26 assert(Youtube
.owns_url
?('http://www.youtube.com/watch?v=SudixyugiX4&hl=en'))
27 assert(Youtube
.owns_url
?('http://youtube.com/watch?v=SudixyugiX4&hl=en'))
28 assert(Youtube
.owns_url
?('http://www.youtube.com/v/SudixyugiX4'))
29 assert(Youtube
.owns_url
?('http://www.youtube.com/v/SudixyugiX4&hl=en'))
30 assert(Youtube
.owns_url
?('http://youtube.com/v/SudixyugiX4&hl=en'))
34 def test_doesnt_own_redtube_urls
35 assert(!Youtube
.owns_url
?('http://www.redtube.com/6807'))
36 assert(!Youtube
.owns_url
?('www.redtube.com/6807'))
37 assert(!Youtube
.owns_url
?('http://redtube.com/6807'))
38 assert(!Youtube
.owns_url
?('redtube.com/6807'))
42 def test_parse_video_id
44 expected_result
= 'SudixyugiX4'
45 actual_result
= yt
.send('parse_video_id', 'http://www.youtube.com/watch?v=SudixyugiX4')
46 assert_equal(expected_result
, actual_result
)
50 def test_parse_t_parameter
55 File
.open('test/fixtures/youtube/SudixyugiX4.html') do |f
|
59 expected_result
= 'OEgsToPDskLQUAntWWpzhEMhBMlgqHdo'
60 actual_result
= yt
.send('parse_t_parameter', page_data
)
61 assert_equal(expected_result
, actual_result
)