File: Biblio_biofetch.t

package info (click to toggle)
bioperl 1.0-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 10,784 kB
  • ctags: 4,962
  • sloc: perl: 70,732; xml: 3,279; lisp: 107; makefile: 53
file content (116 lines) | stat: -rw-r--r-- 2,753 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# This is -*-Perl-*- code
## Bioperl Test Harness Script for Modules
##
# $Id: Biblio_biofetch.t,v 1.3.2.3 2002/03/17 00:48:49 jason Exp $

# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl test.t'

use strict;
use vars qw($NUMTESTS $DEBUG);
$DEBUG=0;
my $error;

BEGIN { 
    # to handle systems with no installed Test module
    # we include the t dir (where a copy of Test.pm is located)
    # as a fallback
    eval { require Test; };
    $error = 0;
    if( $@ ) {
	use lib 't';
    }
    use Test;

    $NUMTESTS = 13;
    plan tests => $NUMTESTS;
    eval { require 'IO/String.pm' };
    if( $@ ) {
	print STDERR "IO::String not installed. This means the Bio::DB::* modules are not usable. Skipping tests.\n";
	for( 1..$NUMTESTS ) {
	    skip(1,"IO::String not installed. This means the Bio::DB::* modules are not usable. Skipping tests");
	}
       $error = 1; 
    }
}

if( $error ==  1 ) {
    exit(0);
}

use Bio::Biblio;
ok 1;
use Bio::Biblio::IO;
ok 1;

## End of black magic.
##
## Insert additional test code below but remember to change
## the print "1..x\n" in the BEGIN block to reflect the
## total number of tests that will be run. 

my ($db,$ref,$refio);
# get a single ref

my $verbose = 0;

$ref = $refio = undef;

# check BioFetch access method


eval { 
    ok ($db = new Bio::Biblio (-access => 'biofetch',
				   -verbose=>$verbose));
    ok(defined($ref = $db->get_by_id('20063307')));
    ok $ref->identifier, '20063307';
};

if ($@) {
    print STDERR "Warning: Couldn't connect to BioFetch server with Bio::DB::Medline.pm!\n";
	print STDERR $@ if( $DEBUG );

    foreach ( $Test::ntest..$NUMTESTS) { 
	skip(1,'could not connect to Medline');}
}

$ref = $refio = undef;

eval {
    ok defined($db = new Bio::Biblio(-access => 'biofetch',
				     -verbose=>$verbose,
				     -retrievaltype => 'tempfile'
				     )); 


    my $ids = ['20063307', '98276153'];
    ok(defined($refio = $db->get_all($ids)));
    ok($refio->next_bibref->identifier, '20063307');
    ok($refio->next_bibref->identifier, '98276153');
};

if ($@) {    
    if( $DEBUG ) { 
	warn "Batch access test failed.Error: $@\n";
    }
    foreach ( $Test::ntest..$NUMTESTS ) { skip('no network access',1); }
}

eval {
    ok defined($db = new Bio::Biblio(-access => 'biofetch',
				     -verbose=>$verbose
				     )); 

    ok(defined($refio = $db->get_Stream_by_batch(['20063307', '98276153'])));
    ok($refio->next_bibref->identifier, '20063307');
    ok($refio->next_bibref->identifier, '98276153');
};

if ($@) {    
    if( $DEBUG ) { 
	warn "Batch access test failed.Error: $@\n";
    }
    foreach ( $Test::ntest..$NUMTESTS ) { skip('no network access',1); }
}