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/tnaflix'
22 class TnaflixTest
< Test
::Unit::TestCase
24 def test_parse_video_id
25 tna
= Tnaflix
.new('http://www.tnaflix.com/view_video.php?viewkey=c831fefc21b6bd58a012')
26 video_id
= tna
.send('parse_video_id')
27 assert_equal('c831fefc21b6bd58a012', video_id
)
31 def test_parse_second_video_id
32 tna
= Tnaflix
.new('http://www.tnaflix.com/view_video.php?viewkey=86b08c10d3e25d277b68')
33 video_id
= tna
.send('parse_video_id')
34 assert_equal('86b08c10d3e25d277b68', video_id
)
38 def test_parse_third_video_id
39 tna
= Tnaflix
.new('http://www.tnaflix.com/view_video.php?viewkey=c831fefc21b6bd58a012&player=old')
40 video_id
= tna
.send('parse_video_id')
41 assert_equal('c831fefc21b6bd58a012', video_id
)
45 def test_parse_fourth_video_id
46 tna
= Tnaflix
.new('http://www.tnaflix.com/view_video.php?viewkey=86b08c10d3e25d277b68&player=old')
47 video_id
= tna
.send('parse_video_id')
48 assert_equal('86b08c10d3e25d277b68', video_id
)
52 def test_parse_video_url
53 tna
= Tnaflix
.new(nil)
57 File
.open('test/fixtures/tnaflix/c831fefc21b6bd58a012.html') do |f
|
61 actual_result
= tna
.send('parse_video_url', page_data
)
62 expected_result
= 'http://cdnt.tnaflix.com/videos/c8/c831fefc21b6bd58a012.flv?key=af67396eb0d05897c13e396ce78da277'
64 assert_equal(expected_result
, actual_result
)
68 def test_second_parse_video_url
69 tna
= Tnaflix
.new(nil)
73 File
.open('test/fixtures/tnaflix/86b08c10d3e25d277b68.html') do |f
|
77 actual_result
= tna
.send('parse_video_url', page_data
)
78 expected_result
= 'http://cdnt.tnaflix.com/videos/86/86b08c10d3e25d277b68.flv?key=157c6255df3296ff5cf06582e3b70273'
80 assert_equal(expected_result
, actual_result
)
85 def test_owns_tnaflix_urls
86 assert(Tnaflix
.owns_url
?('http://www.tnaflix.com/view_video.php?viewkey=86b08c10d3e25d277b68'))
87 assert(Tnaflix
.owns_url
?('http://www.tnaflix.com/view_video.php?viewkey=86b08c10d3e25d277b68&player=old'))
88 assert(Tnaflix
.owns_url
?('http://www.tnaflix.com/view_video.php?viewkey=86b08c10d3e25d277b68'))
89 assert(Tnaflix
.owns_url
?('http://www.tnaflix.com/view_video.php?viewkey=86b08c10d3e25d277b68&player=old'))
93 def test_doesnt_own_redtube_urls
94 assert(!Tnaflix
.owns_url
?('http://www.redtube.com/6807'))
95 assert(!Tnaflix
.owns_url
?('www.redtube.com/6807'))
96 assert(!Tnaflix
.owns_url
?('http://redtube.com/6807'))
97 assert(!Tnaflix
.owns_url
?('redtube.com/6807'))