]> gitweb.michael.orlitzky.com - dead/whatever-dl.git/blob - test/uri_utilities_remote_test.rb
f8c6b8db354fe92bf1970b7520622c830304d903
[dead/whatever-dl.git] / test / uri_utilities_remote_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/uri_utilities.rb'
21
22 class UriUtilitiesTest < Test::Unit::TestCase
23
24 # Test that we get a 404 error for a nonexistent page.
25 def test_404_on_nonexistent_page
26 uu = UriUtilities.new()
27
28 # *Hopefully* this connection is refused.
29 example_uri = 'http://www.example.com/test-nonexistent-page.html'
30 uri = URI.parse(example_uri)
31
32 assert_raise OpenURI::HTTPError do
33 uu.download_with_progress_bar(uri, 'dummy.tmp')
34 end
35
36 # This should be gone since there was an HTTP error.
37 assert(!File.exists?('dummy.tmp'))
38 end
39
40 end