[bug 2707]
[bioperl-live.git] / t / Biblio / biofetch.t
blob862d77bcefc025853c02b88beec2976b03e60685
1 # -*-Perl-*- Test Harness script for Bioperl
2 # $Id$
4 use strict;
6 BEGIN { 
7         use lib '.';
8     use Bio::Root::Test;
9     
10     test_begin(-tests => 12,
11                            -requires_modules => [qw(IO::String
12                                                                             LWP::Simple
13                                                                                 HTTP::Request::Common)],
14                -requires_networking => 1);
15         
16         use_ok('Bio::Biblio');
19 my ($db,$ref,$refio);
20 # get a single ref
22 my $verbose =  test_debug();
24 $ref = $refio = undef;
26 SKIP: {
27         # check BioFetch access method
28         ok ($db = Bio::Biblio->new(-access => 'biofetch',
29                                                            -verbose => $verbose));
30         eval { 
31                 $ref = $db->get_by_id('10592273');
32         };
33         
34         if ($@) {
35                 skip( "Warning: Couldn't connect to BioFetch server with Bio::DB::Biblio::biofetch! $@", 10); 
36         }
37         ok(defined($ref)); 
38         is $ref->identifier, '10592273';
39         $ref = $refio = undef;
40         
41         ok defined($db = Bio::Biblio->new(-access => 'biofetch',
42                                                                           -verbose => $verbose)); 
43         
44         my $ids = ['10592273', '9613206'];
45         eval {
46                 $refio = $db->get_all($ids);
47         };
48         
49         if ($@) {
50                 skip("Batch access test failed. Error: $@", 7);
51         }
52         
53         ok(defined($refio));
54         is($refio->next_bibref->identifier, '9613206');
55         is($refio->next_bibref->identifier, '10592273');
56         
57         ok defined($db = Bio::Biblio->new(-access => 'biofetch',
58                                                                           -verbose => $verbose)); 
59         eval {
60                 $refio = $db->get_Stream_by_id(['10592273', '9613206']);
61         };
62         
63         if ($@) {    
64                 skip("Batch access test failed. Error: $@", 3);
65         }
66         
67         ok(defined($refio));    
68         is($refio->next_bibref->identifier, '9613206');
69         is($refio->next_bibref->identifier, '10592273');