maint: remove Travis stuff which has been replaced with Github actions (#325)
[bioperl-live.git] / t / Root / HTTPget.t
blob1096bda23417e08d5cc17daafa44c1359d1866f4
1 # -*-Perl-*- Test Harness script for Bioperl
3 use strict;
4 use warnings;
6 BEGIN {
7     use Bio::Root::Test;
8     
9     test_begin(-tests => 29,
10                -requires_networking => 1);
11         
12     use_ok('Bio::Root::HTTPget');
15 my $TESTURL = 'http://www.google.com/index.html';
17 my $TEST_PROXY = 'http://myproxy';
19 my @TEST_AUTHENTICATION = qw(foo bar);
21 my ($fh, $proxy);
23 my @auth;
25 =head1 Bio::Root::HTTPget comments
27 This module is a bit schizophrenic in that it is called in three different
28 ways; as an instance method, a class method, or as an explicit subroutine.
30 These tests check for all call types.  They are by no means incomplete.
32 =cut 
34 # test object method calls
35 my $obj = Bio::Root::HTTPget->new();
37 ok defined($obj) && $obj->isa('Bio::Root::Root');
39 lives_ok {$obj->get($TESTURL)};
40 lives_ok {$fh = $obj->getFH($TESTURL)};
41 isa_ok($fh, 'IO::Socket::INET');
43 undef($fh);
45 is ($obj->proxy(), undef);
46 is_deeply([$obj->authentication], []);
47 $obj->proxy('http', $TEST_PROXY);
48 $obj->authentication(@TEST_AUTHENTICATION);
49 is ($obj->proxy(), $TEST_PROXY);
50 is_deeply([$obj->authentication], \@TEST_AUTHENTICATION);
52 # test class method calls; note that mixing class and sub calls pollutes the
53 # class attributes
55 lives_ok {Bio::Root::HTTPget->get($TESTURL)};
56 lives_ok {$fh = Bio::Root::HTTPget->getFH($TESTURL)};
57 isa_ok($fh, 'IO::Socket::INET');
59 undef($fh);
61 is (Bio::Root::HTTPget->proxy(), undef);
62 is_deeply([Bio::Root::HTTPget->authentication], []);
63 Bio::Root::HTTPget->proxy('http', $TEST_PROXY);
64 Bio::Root::HTTPget->authentication(@TEST_AUTHENTICATION);
65 is (Bio::Root::HTTPget->proxy('http'), $TEST_PROXY);
66 is_deeply([Bio::Root::HTTPget->authentication], \@TEST_AUTHENTICATION);
68 # test sub calls (not called as method)
70 lives_ok {Bio::Root::HTTPget::get($TESTURL)};
71 lives_ok {$fh = Bio::Root::HTTPget::getFH($TESTURL)};
72 isa_ok($fh, 'IO::Socket::INET');
74 undef($fh);
76 # note that mixing class and sub calls pollutes the class attributes, have to
77 # manually reset
78 Bio::Root::HTTPget->authentication(undef, undef);
80 my $old = Bio::Root::HTTPget->clear_proxy('http');
81 is (Bio::Root::HTTPget::proxy(), undef);
82 is ($old, $TEST_PROXY);
84 is_deeply([Bio::Root::HTTPget->authentication], [undef, undef]);
85 Bio::Root::HTTPget::proxy('http', $TEST_PROXY);
86 Bio::Root::HTTPget::authentication(@TEST_AUTHENTICATION);
87 is (Bio::Root::HTTPget::proxy('http'), $TEST_PROXY);
88 is_deeply([Bio::Root::HTTPget->authentication], \@TEST_AUTHENTICATION);
90 # check to make sure new instance attributes are not polluted by class attrbutes
91 # from previous tests
93 my $newobj = Bio::Root::HTTPget->new();
95 ok defined($newobj) && $obj->isa('Bio::Root::Root');
97 is ($newobj->proxy(), undef);
98 is_deeply([$newobj->authentication], []);
99 $newobj->proxy('http', $TEST_PROXY);
100 $newobj->authentication(@TEST_AUTHENTICATION);
101 is ($newobj->proxy(), $TEST_PROXY);
102 is_deeply([$newobj->authentication], \@TEST_AUTHENTICATION);