]> gitweb.michael.orlitzky.com - dead/whatever-dl.git/blob - test/tnaflix_test.rb
Merged upstream branch (master).
[dead/whatever-dl.git] / test / tnaflix_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/tnaflix'
21
22 class TnaflixTest < Test::Unit::TestCase
23
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)
28 end
29
30
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)
35 end
36
37
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)
42 end
43
44
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)
49 end
50
51
52 def test_parse_video_url
53 tna = Tnaflix.new(nil)
54
55 page_data = nil
56
57 File.open('test/fixtures/tnaflix/c831fefc21b6bd58a012.html') do |f|
58 page_data = f.read
59 end
60
61 actual_result = tna.send('parse_video_url', page_data)
62 expected_result = 'http://cdnt.tnaflix.com/videos/c8/c831fefc21b6bd58a012.flv?key=af67396eb0d05897c13e396ce78da277'
63
64 assert_equal(expected_result, actual_result)
65 end
66
67
68 def test_second_parse_video_url
69 tna = Tnaflix.new(nil)
70
71 page_data = nil
72
73 File.open('test/fixtures/tnaflix/86b08c10d3e25d277b68.html') do |f|
74 page_data = f.read
75 end
76
77 actual_result = tna.send('parse_video_url', page_data)
78 expected_result = 'http://cdnt.tnaflix.com/videos/86/86b08c10d3e25d277b68.flv?key=157c6255df3296ff5cf06582e3b70273'
79
80 assert_equal(expected_result, actual_result)
81 end
82
83
84
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'))
90 end
91
92
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'))
98 end
99 end