X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=test%2Fdailymotion_test.rb;fp=test%2Fdailymotion_test.rb;h=25ae4630490daf1d11a6cf1f21de5d387cd251b4;hb=455d65b183518c9fb23470cc5f3a987046de0965;hp=0000000000000000000000000000000000000000;hpb=11aa7c3e702f4ea466152b706f60e154e60e188e;p=dead%2Fwhatever-dl.git diff --git a/test/dailymotion_test.rb b/test/dailymotion_test.rb new file mode 100644 index 0000000..25ae463 --- /dev/null +++ b/test/dailymotion_test.rb @@ -0,0 +1,58 @@ +# +# Copyright Michael Orlitzky +# +# http://michael.orlitzky.com/ +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# http://www.fsf.org/licensing/licenses/gpl.html +# + +require 'test/unit' +require 'src/websites/dailymotion' + + +class DailymotionTest < Test::Unit::TestCase + + def test_owns_dailymotion_urls + assert(Dailymotion.owns_url?('http://www.dailymotion.com/video/xavgrm_japanese-cosplay-babes_news#hp-v-v8')) + assert(Dailymotion.owns_url?('http://www.dailymotion.com/video/xavgrm_japanese-cosplay-babes_news')) + assert(Dailymotion.owns_url?('http://www.dailymotion.com/video/xcuw24_penn-edgar-feature_sport#hp-v-v5')) + assert(Dailymotion.owns_url?('http://www.dailymotion.com/video/xcuw24_penn-edgar-feature_sport')) + assert(Dailymotion.owns_url?('http://www.dailymotion.com/video/x241fi_epic-movie-mrs-new-booty')) + end + + + def test_doesnt_own_infoq_urls + assert(!Dailymotion.owns_url?('http://www.infoq.com/interviews/jim-weirich-discusses-rake')) + end + + + def test_doesnt_own_efukt_urls + assert(!Dailymotion.owns_url?('http://www.efukt.com/2308_How_To_Fuck_Like_A_King.html')) + assert(!Dailymotion.owns_url?('http://www.efukt.com/2304_The_Dumbest_Porno_Ever_Made.html')) + end + + + def test_parse_video_url + ft = Dailymotion.new(nil) + + page_data = nil + + File.open('test/fixtures/dailymotion/ms_new_booty.html') do |f| + page_data = f.read + end + + test_result = ft.send('parse_video_url', page_data) + assert_equal('http://www.dailymotion.com/cdn/FLV-320x240/video/x241fi.flv?auth=1271704672-bc7bb7d6447e816d9247908b89407d3e', test_result) + end + +end