~ubuntu-branches/ubuntu/trusty/bioperl/trusty-proposed

« back to all changes in this revision

Viewing changes to t/RemoteDB/HIV/HIV.t

  • Committer: Bazaar Package Importer
  • Author(s): Charles Plessy
  • Date: 2009-03-10 07:19:11 UTC
  • mfrom: (1.2.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20090310071911-fukqzw54pyb1f0bd
Tags: 1.6.0-2
* Removed patch system (not used):
  - removed instuctions in debian/rules;
  - removed quilt from Build-Depends in debian/control.
* Re-enabled tests:
  - uncommented test command in debian/rules;
  - uncommented previously missing build-dependencies in debian/control.
  - Re-enabled tests and uncommented build-dependencies accordingly.
* Removed libmodule-build-perl and libtest-harness-perl from
  Build-Depends-Indep (provided by perl-modules).
* Better cleaning of empty directories using find -type d -empty -delete
  instead of rmdir in debian/rules (LP: #324001).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# testing Bio::DB::HIV
 
2
#$Id: HIV.t 232 2008-12-11 14:51:51Z maj $#
 
3
use strict;
 
4
use warnings;
 
5
 
 
6
BEGIN {
 
7
    use Bio::Root::Test;
 
8
    test_begin(
 
9
        -tests => 30,
 
10
        -requires_modules => [qw( XML::Simple HTTP::Request::Common)],
 
11
        );
 
12
    use_ok('Bio::DB::HIV');
 
13
    use_ok('Bio::DB::WebDBSeqI');
 
14
    use_ok('Bio::DB::HIV::HIVAnnotProcessor');
 
15
}
 
16
 
 
17
my $tobj= Bio::DB::HIV->new();
 
18
 
 
19
$tobj->ua->timeout(90);
 
20
 
 
21
#object tests
 
22
isa_ok($tobj, 'Bio::DB::HIV');
 
23
 
 
24
#compliance tests
 
25
isa_ok($tobj, 'Bio::Root::Root');
 
26
can_ok($tobj, qw( get_request postprocess_data ));
 
27
 
 
28
#methods
 
29
can_ok($tobj, qw( get_seq_stream get_Stream_by_acc get_Stream_by_query _request ));
 
30
 
 
31
#internals
 
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 ));
 
33
 
 
34
# defaults tests
 
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)');
 
41
 
 
42
#todos
 
43
throws_ok { $tobj->get_request('mode'=>'version', 'uids'=>['K03455.1']) } qr/Bio::HIVSorry::Exception/, 'sorry till implemented';
 
44
 
 
45
throws_ok {$tobj->get_request('mode'=>'gi', 'uids'=>['1906382'])} qr/Bio::HIVSorry::Exception/, 'sorry till implemented';
 
46
 
 
47
#exception tests
 
48
my $badq = bless({}, "Not::A::Query");
 
49
throws_ok {$tobj->get_Stream_by_query($badq)} qr/HIVQuery required/, 'HIVQuery type exception check';
 
50
 
 
51
# network tests
 
52
SKIP: {
 
53
    test_skip(-tests => 13,
 
54
          -requires_networking => 1);
 
55
    
 
56
    # WebDBSeqI compliance-
 
57
    # (this requires network access, since request is built after establishing
 
58
    # the LANL session...)
 
59
    my $req;
 
60
    lives_ok {$req = $tobj->get_request('mode'=>'single','uids'=>['17756'])} 'test connection';
 
61
    if ($@) {
 
62
        skip("Network problems, skipping all tests", 12)
 
63
    }
 
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';
 
67
    if ($@) {
 
68
        skip("Network problems, skipping all tests", 10)
 
69
    }
 
70
    lives_ok { $tobj->get_Seq_by_acc('K03455');} 'get HXB2 by GB accession';
 
71
    if ($@) {
 
72
        skip("Network problems, skipping all tests", 9)
 
73
    }    
 
74
    my ($seqio, $hxb2);
 
75
    lives_ok { $seqio = $tobj->get_Stream_by_id(['17756']) } 'get HXB2 in a stream';
 
76
    if ($@) {
 
77
        skip("Network problems, skipping all tests", 8)
 
78
    }
 
79
        
 
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
 
82
        # skip the rest
 
83
        eval { $seqio = $tobj->get_Stream_by_acc(['K03455']) };
 
84
    if ($@) {
 
85
                ok(1, "Server-side request problem, bypassing...");
 
86
        skip("Network problems, skipping all tests", 7)
 
87
    } else {
 
88
                ok(1, 'get HXB2 in a stream by accession');
 
89
        }
 
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');
 
94
    #network exceptions
 
95
        
 
96
    # bad id exception
 
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';
 
101
    # bad url exception
 
102
    $tobj->_session_id('');
 
103
    $tobj->map_db('');
 
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';
 
109
    
 
110
# check ..._by_query functions in HIVQuery.t
 
111
}
 
112
 
 
113