X-Git-Url: https://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=test%2Ftnaflix_test.rb;fp=test%2Ftnaflix_test.rb;h=3bd42d06c081a98dcc88682086b2b73bd8769971;hb=898ac047794bd23c6a60929d484a7e898549752f;hp=0000000000000000000000000000000000000000;hpb=b9ebb66dc6ba56534eaa8280e6220ade7190757d;p=dead%2Fwhatever-dl.git diff --git a/test/tnaflix_test.rb b/test/tnaflix_test.rb new file mode 100644 index 0000000..3bd42d0 --- /dev/null +++ b/test/tnaflix_test.rb @@ -0,0 +1,99 @@ +# +# 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/tnaflix' + +class TnaflixTest < Test::Unit::TestCase + + def test_parse_video_id + tna = Tnaflix.new('http://www.tnaflix.com/view_video.php?viewkey=c831fefc21b6bd58a012') + video_id = tna.send('parse_video_id') + assert_equal('c831fefc21b6bd58a012', video_id) + end + + + def test_parse_second_video_id + tna = Tnaflix.new('http://www.tnaflix.com/view_video.php?viewkey=86b08c10d3e25d277b68') + video_id = tna.send('parse_video_id') + assert_equal('86b08c10d3e25d277b68', video_id) + end + + + def test_parse_third_video_id + tna = Tnaflix.new('http://www.tnaflix.com/view_video.php?viewkey=c831fefc21b6bd58a012&player=old') + video_id = tna.send('parse_video_id') + assert_equal('c831fefc21b6bd58a012', video_id) + end + + + def test_parse_fourth_video_id + tna = Tnaflix.new('http://www.tnaflix.com/view_video.php?viewkey=86b08c10d3e25d277b68&player=old') + video_id = tna.send('parse_video_id') + assert_equal('86b08c10d3e25d277b68', video_id) + end + + + def test_parse_video_url + tna = Tnaflix.new(nil) + + page_data = nil + + File.open('test/fixtures/tnaflix/c831fefc21b6bd58a012.html') do |f| + page_data = f.read + end + + actual_result = tna.send('parse_video_url', page_data) + expected_result = 'http://cdnt.tnaflix.com/videos/c8/c831fefc21b6bd58a012.flv?key=af67396eb0d05897c13e396ce78da277' + + assert_equal(expected_result, actual_result) + end + + + def test_second_parse_video_url + tna = Tnaflix.new(nil) + + page_data = nil + + File.open('test/fixtures/tnaflix/86b08c10d3e25d277b68.html') do |f| + page_data = f.read + end + + actual_result = tna.send('parse_video_url', page_data) + expected_result = 'http://cdnt.tnaflix.com/videos/86/86b08c10d3e25d277b68.flv?key=157c6255df3296ff5cf06582e3b70273' + + assert_equal(expected_result, actual_result) + end + + + + def test_owns_tnaflix_urls + assert(Tnaflix.owns_url?('http://www.tnaflix.com/view_video.php?viewkey=86b08c10d3e25d277b68')) + assert(Tnaflix.owns_url?('http://www.tnaflix.com/view_video.php?viewkey=86b08c10d3e25d277b68&player=old')) + assert(Tnaflix.owns_url?('http://www.tnaflix.com/view_video.php?viewkey=86b08c10d3e25d277b68')) + assert(Tnaflix.owns_url?('http://www.tnaflix.com/view_video.php?viewkey=86b08c10d3e25d277b68&player=old')) + end + + + def test_doesnt_own_redtube_urls + assert(!Tnaflix.owns_url?('http://www.redtube.com/6807')) + assert(!Tnaflix.owns_url?('www.redtube.com/6807')) + assert(!Tnaflix.owns_url?('http://redtube.com/6807')) + assert(!Tnaflix.owns_url?('redtube.com/6807')) + end +end