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/bliptv'
22 class BliptvTest
< Test
::Unit::TestCase
24 def test_owns_bliptv_urls
26 assert(Bliptv
.owns_url
?('http://www.blip.tv/file/2664572?utm_source=featured_ep&utm_medium=featured_ep'))
27 assert(Bliptv
.owns_url
?('www.blip.tv/file/2664572?utm_source=featured_ep&utm_medium=featured_ep'))
28 assert(Bliptv
.owns_url
?('http://www.blip.tv/file/2664626'))
29 assert(Bliptv
.owns_url
?('http://www.blip.tv/file/2664626?utm_source=featured_ep&utm_medium=featured_ep'))
30 assert(Bliptv
.owns_url
?('http://urbansustainableliv.blip.tv/file/1189454/'))
31 assert(Bliptv
.owns_url
?('http://rosa-menkman.blip.tv/file/1947851/'))
32 assert(Bliptv
.owns_url
?('rosa-menkman.blip.tv/file/1947851/'))
33 assert(Bliptv
.owns_url
?('rosa-menkman.blip.tv/file/1947851/?utm_source=featured_ep&utm_medium=featured_ep'))
34 assert(Bliptv
.owns_url
?('rosa-menkman.blip.tv/file/1947851?utm_source=featured_ep&utm_medium=featured_ep'))
35 assert(Bliptv
.owns_url
?('http://www.blip.tv/file/2664626'))
39 def test_doesnt_own_redtube_urls
40 assert(!Bliptv
.owns_url
?('http://www.redtube.com/6807'))
41 assert(!Bliptv
.owns_url
?('www.redtube.com/6807'))
42 assert(!Bliptv
.owns_url
?('http://redtube.com/6807'))
43 assert(!Bliptv
.owns_url
?('redtube.com/6807'))
47 def test_doesnt_own_howcast_urls
48 assert(!Bliptv
.owns_url
?('http://www.howcast.com/videos/6807-2twr'))
49 assert(!Bliptv
.owns_url
?('www.howcast.com/videos/6807-2dgfdg'))
50 assert(!Bliptv
.owns_url
?('http://howcast.com/videos/6807-cse'))
51 assert(!Bliptv
.owns_url
?('howcast.com/videos/6807-asdgasd'))
55 def test_doesnt_own_misc_urls
56 assert(!Bliptv
.owns_url
?('http://www.bliptv.com/123456'))
60 def test_parse_flv_video_url
61 # Here we're trying to parse the video URL out of some standard
62 # blip.tv pages, where the video playing is in FLV format. In both
63 # of these cases, though, we want to parse the source (MOV/WMV)
69 File
.open('test/fixtures/bliptv/1752651.htm') do |f
|
73 test_result
= btv
.send('parse_video_url', page_data
)
74 assert_equal('http://blip.tv/file/get/Esequeira82-AdventuresInEgypt567.wmv', test_result
)
79 File
.open('test/fixtures/bliptv/923819.htm') do |f
|
83 test_result
= btv
.send('parse_video_url', page_data
)
84 assert_equal('http://blip.tv/file/get/Kantel-SadSong186.mov', test_result
)
89 def test_parse_mov_video_url
90 # These fixtures are saved from pages where the high-quality MOV
91 # format was already selected.
96 File
.open('test/fixtures/bliptv/923682-mov.htm') do |f
|
100 test_result
= btv
.send('parse_video_url', page_data
)
101 assert_equal('http://blip.tv/file/get/Kantel-UbiUndPythonDemo816.mov', test_result
)
106 File
.open('test/fixtures/bliptv/923819-mov.htm') do |f
|
110 test_result
= btv
.send('parse_video_url', page_data
)
111 assert_equal('http://blip.tv/file/get/Kantel-SadSong186.mov', test_result
)
116 def test_parse_mp4_video_url
117 # And why not check one of the MP4 pages, too?
119 btv
= Bliptv
.new(nil)
123 File
.open('test/fixtures/bliptv/923682-mp4.htm') do |f
|
127 test_result
= btv
.send('parse_video_url', page_data
)
128 assert_equal('http://blip.tv/file/get/Kantel-UbiUndPythonDemo816.mov', test_result
)
132 def test_parse_mp4_video_url
133 # And why not check one of the MP4 pages, too?
135 btv
= Bliptv
.new(nil)
139 File
.open('test/fixtures/bliptv/923682-no_alternatives.htm') do |f
|
143 test_result
= btv
.send('parse_video_url', page_data
)
144 assert_equal('http://blip.tv/file/get/Kantel-UbiUndPythonDemo816.flv', test_result
)