2
#$Id: HIV.t 232 2008-12-11 14:51:51Z maj $#
10
-requires_modules => [qw( XML::Simple HTTP::Request::Common)],
12
use_ok('Bio::DB::HIV');
13
use_ok('Bio::DB::WebDBSeqI');
14
use_ok('Bio::DB::HIV::HIVAnnotProcessor');
17
my $tobj= Bio::DB::HIV->new();
19
$tobj->ua->timeout(90);
22
isa_ok($tobj, 'Bio::DB::HIV');
25
isa_ok($tobj, 'Bio::Root::Root');
26
can_ok($tobj, qw( get_request postprocess_data ));
29
can_ok($tobj, qw( get_seq_stream get_Stream_by_acc get_Stream_by_query _request ));
32
can_ok($tobj, qw( lanl_base map_db make_search_if search_ _map_db_uri _make_search_if_uri _search_uri _session_id _sorry ));
35
ok($tobj->lanl_base, 'lanl_base set in default object');
36
ok($tobj->map_db, 'map_db set in default object');
37
ok($tobj->make_search_if, 'make_search_if set in default object');
38
ok($tobj->search_, 'search_ set in default object');
39
ok($tobj->url_base_address, 'url_base_address set in default object');
40
is(($tobj->request_format)[0], "fasta", 'default sequence request format (fasta)');
43
throws_ok { $tobj->get_request('mode'=>'version', 'uids'=>['K03455.1']) } qr/Bio::HIVSorry::Exception/, 'sorry till implemented';
45
throws_ok {$tobj->get_request('mode'=>'gi', 'uids'=>['1906382'])} qr/Bio::HIVSorry::Exception/, 'sorry till implemented';
48
my $badq = bless({}, "Not::A::Query");
49
throws_ok {$tobj->get_Stream_by_query($badq)} qr/HIVQuery required/, 'HIVQuery type exception check';
53
test_skip(-tests => 13,
54
-requires_networking => 1);
56
# WebDBSeqI compliance-
57
# (this requires network access, since request is built after establishing
58
# the LANL session...)
60
lives_ok {$req = $tobj->get_request('mode'=>'single','uids'=>['17756'])} 'test connection';
62
skip("Network problems, skipping all tests", 12)
64
isa_ok($req, 'HTTP::Request', 'Object returned from get_request');
65
# get_... functionality
66
lives_ok { $tobj->get_Seq_by_id('17756') } 'get HXB2 by LANL id';
68
skip("Network problems, skipping all tests", 10)
70
lives_ok { $tobj->get_Seq_by_acc('K03455');} 'get HXB2 by GB accession';
72
skip("Network problems, skipping all tests", 9)
75
lives_ok { $seqio = $tobj->get_Stream_by_id(['17756']) } 'get HXB2 in a stream';
77
skip("Network problems, skipping all tests", 8)
80
# this test seems to fail ~50% of the time (server-side issue), so we tread
81
# lightly with an eval and pass regardless, but indicate the problem and
83
eval { $seqio = $tobj->get_Stream_by_acc(['K03455']) };
85
ok(1, "Server-side request problem, bypassing...");
86
skip("Network problems, skipping all tests", 7)
88
ok(1, 'get HXB2 in a stream by accession');
90
$hxb2 = $seqio->next_seq;
91
is($hxb2->primary_id, 'K03455', 'checking returned stream');
92
is($hxb2->alphabet,'dna', 'checking returned stream');
93
ok(!($hxb2->seq !~ /atgc/i), 'checking returned sequence');
97
throws_ok { $tobj->get_Seq_by_id('XXXXXX') } qr/no sequences found/i, 'bad id exception check';
98
# session id exception
99
$tobj->_session_id('555-1212');
100
throws_ok {$tobj->get_Seq_by_id('17756')} qr/request failed/, 'bad session exception check';
102
$tobj->_session_id('');
104
$tobj->url_base_address('http://socrates_jones_et_cie.us');
105
throws_ok {$tobj->get_Seq_by_id('17756')} qr/Connect failed/, 'bad url exception check';
106
# wrong url exception
107
$tobj->url_base_address('http://fortinbras.us');
108
throws_ok {$tobj->get_Seq_by_id('17756')} qr/Session not established/, 'wrong url exception check';
110
# check ..._by_query functions in HIVQuery.t