]> gitweb.michael.orlitzky.com - dead/whatever-dl.git/blob - test/motherless_test.rb
3b89ef0e6e1963efa766ded9472b5e11ba715eb2
[dead/whatever-dl.git] / test / motherless_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/motherless'
21
22 class MotherlessTest < Test::Unit::TestCase
23
24 def test_owns_motherless_urls
25 assert(Motherless.owns_url?('http://motherless.com/C1D5A7A'))
26 assert(Motherless.owns_url?('http://www.motherless.com/C1D5960'))
27 end
28
29
30 def test_doesnt_own_redtube_urls
31 assert(!Motherless.owns_url?('http://www.redtube.com/6807'))
32 assert(!Motherless.owns_url?('www.redtube.com/6807'))
33 assert(!Motherless.owns_url?('http://redtube.com/6807'))
34 assert(!Motherless.owns_url?('redtube.com/6807'))
35 end
36
37
38 def test_doesnt_own_howcast_urls
39 assert(!Motherless.owns_url?('http://www.howcast.com/videos/6807-2twr'))
40 assert(!Motherless.owns_url?('www.howcast.com/videos/6807-2dgfdg'))
41 assert(!Motherless.owns_url?('http://howcast.com/videos/6807-cse'))
42 assert(!Motherless.owns_url?('howcast.com/videos/6807-asdgasd'))
43 end
44
45
46 def test_doesnt_own_misc_urls
47 assert(!Motherless.owns_url?('http://www.bliptv.com/123456'))
48 end
49
50
51 def test_parse_video_url
52 ml = Motherless.new(nil)
53
54 page_data = nil
55
56 # First Fixture
57
58 File.open('test/fixtures/motherless/C1D5960.html') do |f|
59 page_data = f.read
60 end
61
62 test_result = ml.send('parse_video_url', page_data)
63 assert_equal('http://members.motherless.com/movies/C1D5960-204299206.flv', test_result)
64
65
66 # Second Fixture
67
68 File.open('test/fixtures/motherless/C1CDA5D.html') do |f|
69 page_data = f.read
70 end
71
72 test_result = ml.send('parse_video_url', page_data)
73 assert_equal('http://members.motherless.com/movies/C1CDA5D-204266691.flv', test_result)
74 end
75
76 end