]> gitweb.michael.orlitzky.com - dead/whatever-dl.git/blob - test/dailymotion_test.rb
Add support for dailymotion.com, with tests.
[dead/whatever-dl.git] / test / dailymotion_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/dailymotion'
21
22
23 class DailymotionTest < Test::Unit::TestCase
24
25 def test_owns_dailymotion_urls
26 assert(Dailymotion.owns_url?('http://www.dailymotion.com/video/xavgrm_japanese-cosplay-babes_news#hp-v-v8'))
27 assert(Dailymotion.owns_url?('http://www.dailymotion.com/video/xavgrm_japanese-cosplay-babes_news'))
28 assert(Dailymotion.owns_url?('http://www.dailymotion.com/video/xcuw24_penn-edgar-feature_sport#hp-v-v5'))
29 assert(Dailymotion.owns_url?('http://www.dailymotion.com/video/xcuw24_penn-edgar-feature_sport'))
30 assert(Dailymotion.owns_url?('http://www.dailymotion.com/video/x241fi_epic-movie-mrs-new-booty'))
31 end
32
33
34 def test_doesnt_own_infoq_urls
35 assert(!Dailymotion.owns_url?('http://www.infoq.com/interviews/jim-weirich-discusses-rake'))
36 end
37
38
39 def test_doesnt_own_efukt_urls
40 assert(!Dailymotion.owns_url?('http://www.efukt.com/2308_How_To_Fuck_Like_A_King.html'))
41 assert(!Dailymotion.owns_url?('http://www.efukt.com/2304_The_Dumbest_Porno_Ever_Made.html'))
42 end
43
44
45 def test_parse_video_url
46 ft = Dailymotion.new(nil)
47
48 page_data = nil
49
50 File.open('test/fixtures/dailymotion/ms_new_booty.html') do |f|
51 page_data = f.read
52 end
53
54 test_result = ft.send('parse_video_url', page_data)
55 assert_equal('http://www.dailymotion.com/cdn/FLV-320x240/video/x241fi.flv?auth=1271704672-bc7bb7d6447e816d9247908b89407d3e', test_result)
56 end
57
58 end