1 # This is -*-Perl-*- code
2 ## Bioperl Test Harness Script for Modules
6 # Before `make install' is performed this script should be runnable with
7 # `make test'. After `make install' it should work as `perl Analysis_soap.t'
10 use vars qw($NUMTESTS);
11 use lib '..','./blib/lib';
16 # to handle systems with no installed Test module
17 # we include the t dir (where a copy of Test.pm is located)
19 eval { require Test; };
26 plan tests => $NUMTESTS;
32 ## End of black magic.
34 ## Insert additional test code below but remember to change
35 ## the 'plan tests =>...' in the BEGIN block to reflect the
36 ## total number of tests that will be run.
40 my $format = ($ENV{'TEST_DETAILS'} ? '%-40s' : '');
43 eval { require Bio::Tools::Run::Analysis };
44 print sprintf ($format, 'use Bio::Tools::Run::Analysis '); ok (%Bio::Tools::Run::Analysis::);
48 # Here I should add some tests for the various methods doing just
51 # the rest makes sense only with SOAP::Lite installed
52 unless (eval "require SOAP::Lite; 1;") {
53 print STDERR "SOAP::Lite not installed. Skipping some tests.\n";
57 foreach ( $Test::ntest..$NUMTESTS) {
63 # check 'new with a default access...'
65 #eval { $seqret = new Bio::Tools::Run::Analysis (-name => 'edit.seqret'); };
66 $seqret = new Bio::Tools::Run::Analysis (-name => 'edit.seqret');
67 print sprintf ($format, 'new ...Analysis (-name=>seqret) '); skip ($serror, defined $seqret);
70 # the rest makes sense only if an Analysis object was created
72 foreach ($Test::ntest..$NUMTESTS) {
79 # check if the remote service is accessible
80 print sprintf ($format, 'checking service availability ');
81 eval { $seqret->analysis_name };
83 print STDERR "Warning: Couldn't connect to $$seqret{'_location'}.\n" . $@;
84 foreach ( $Test::ntest..$NUMTESTS) {
85 skip ('skip (probably) because of no network access',1);
92 # some testing data (for seqret)
94 my %inputs = ('sequence_direct_data' => $seq,
98 # check using a real service
99 print sprintf ($format, 'calling "analysis_name" ');
100 skip ($serror, eval { 'seqret' eq $seqret->analysis_name });
103 print sprintf ($format, 'calling "analysis_spec" ');
104 skip ($serror, eval { ref ($seqret->analysis_spec) eq 'HASH' });
108 print sprintf ($format, 'calling "input_spec" ');
109 eval { $spec = $seqret->input_spec };
110 skip ($serror, ref ($spec) eq 'ARRAY' && @$spec > 0 && ref ($$spec[0]) eq 'HASH');
113 print sprintf ($format, 'calling "result_spec" ');
114 eval { $spec = $seqret->result_spec };
115 skip ($serror, ref ($spec) eq 'ARRAY' && @$spec > 0 && ref ($$spec[0]) eq 'HASH');
118 print sprintf ($format, 'calling "describe" ');
119 skip ($serror, eval { $seqret->describe =~ /^<\?xml / });
123 print sprintf ($format, 'calling "create_job" ');
124 eval { $job = $seqret->create_job (\%inputs) };
125 skip ($serror, ref ($job) =~ /^Bio::Tools::Run::Analysis::Job/);
128 my $next_dependent_tests = 4;
130 print sprintf ($format, 'calling "job->status" ');
131 skip ($serror, eval { $job->status eq 'CREATED' });
135 eval { $clone_job = $seqret->create_job ($job->{'_id'}) };
136 print sprintf ($format, 'cloning job ');
137 skip ($serror, ref ($clone_job) =~ /^Bio::Tools::Run::Analysis::Job/);
140 $next_dependent_tests = 2;
142 print sprintf ($format, 'calling "new_job->last_event" ');
143 skip ($serror, eval { $clone_job->last_event =~ /^<\?xml / });
146 print sprintf ($format, 'calling "new_job->remove" ');
147 eval { $clone_job->remove };
148 skip ($serror, $clone_job->{'_destroy_on_exit'} == 1);
151 &skip_tests ($next_dependent_tests);
154 &skip_tests ($next_dependent_tests);
158 #eval { $empty_job = $seqret->create_job() };
159 #print sprintf ($format, 'creating an empty job ');
160 #skip ($serror, ref ($empty_job) =~ /^Bio::Tools::Run::Analysis::Job/);
163 #$next_dependent_tests = 1;
166 ## TBD (should be mentioned in TODO)
167 ## print sprintf ($format, 'calling "empty_job->status" ');
168 ## skip ($serror, eval { $empty_job->status eq 'CREATED' });
171 # print sprintf ($format, 'calling "empty_job->remove" ');
172 # eval { $empty_job->remove };
173 # skip ($serror, $empty_job->{'_destroy_on_exit'} == 1);
176 # &skip_tests ($next_dependent_tests);
179 print sprintf ($format, 'calling "wait_for" ');
180 eval { $job = $seqret->wait_for (\%inputs) };
181 skip ($serror, ref ($job) =~ /^Bio::Tools::Run::Analysis::Job/);
184 $next_dependent_tests = 3;
187 # repeated calls to results() retrieves empty hashes;
188 # cache hash ref in a variable
189 my $results = $job->results;
191 print sprintf ($format, 'checking "detailed_status" ');
192 skip ($serror, eval { $results->{'detailed_status'} == 0 });
195 print sprintf ($format, 'checking "report" ');
196 skip ($serror, eval { $results->{'report'} =~ /successfully/i });
199 print sprintf ($format, 'checking "outseq" ');
200 skip ($serror, eval { $results->{'outseq'} =~ /^$seq$/ });
204 &skip_tests ($next_dependent_tests);
209 # skip the next $count tests
212 my $msg = "skip because of failure in test " . ($Test::ntest - 1);
213 foreach ( $Test::ntest..($Test::ntest + $count - 1)) {
218 # print an error on stderr if there is an error and TEST_DETAILS is on
220 print STDERR $@ if $@ && $ENV{'TEST_DETAILS'};