Skip to content

Commit

Permalink
all tests pass, but status is not captured yet
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Fields committed Dec 15, 2011
1 parent 88a8c38 commit 48bf5f6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 48 deletions.
42 changes: 9 additions & 33 deletions Bio/DB/SeqVersion/gi.pm
Expand Up @@ -228,7 +228,6 @@ sub _get_request {
. $response->status_line . "\n"
. "ID likely does not exist" );
}
$self->debug( "Response is:\n", $response->content, "\n" );
return $response->content;
}

Expand All @@ -244,40 +243,17 @@ sub _get_request {

sub _process_data {
my ( $self, $html ) = @_;
my @table = ();
my $count = 0;

my $te = HTML::TableExtract->new( headers => ['Version', 'Gi', 'Update Date'] );
# TODO: this is a quick patch, the status is not currently captured as
# it lies outside the table
my $te = HTML::TableExtract->new(
headers => ['Gi', 'Version', 'Update Date'] ,
depth => 0);
$te->parse($html);

# Examine all matching tables
foreach my $ts ($te->tables) {
print STDERR "Table (", join(',', $ts->coords), "):\n";
foreach my $row ($ts->rows) {
print STDERR join(',', @$row), "\n";
}
}
#while ( my $token = $p->get_tag('td') ) {
#
# #print Dumper $token;
# print STDERR $p->get_text . "\n";
#}

#if ($html =~ /Current\s+status:\s+([a-z]+)<\/div>(<table.+)/xms) {
# ($status, $table) = ($1, $2);
#} else {
# $self->throw("Could not parse 'Revision history' HTML table: \n$html")
#}
#my (@rows) = $table =~ /<tr>(.+?)<\/tr>/g;
#shift @rows; # get rid of header
#for my $row (@rows) {
# my (@arr) = $row =~ />([^<>]+)/g;
# $table[$count] = \@arr;
# $count++;
#}
#$self->throw("Bad table data: \n".join("\n",@rows)) unless @table > 1;
#print Dumper \@table;
\@table;
my $table = $te->first_table_found;
$self->throw("No table found") unless defined $table;
my $t = [$table->rows];
($t, 1); # the prior version never returned a status...
}

1;
Expand Down
30 changes: 15 additions & 15 deletions t/RemoteDB/SeqVersion.t
Expand Up @@ -25,21 +25,21 @@ SKIP: {
qr/ID likely does not exist/i, 'throw on bad ID';

my $latest_gi = $query->get_recent(2);
#is($latest_gi, 2, 'get_recent');
#
#my @all_gis = $query->get_all(2);
#cmp_ok(@all_gis, '>=', 8, 'get_all');

#my $latest_gi = $query->get_recent('A00002');
#is($latest_gi, 2, 'get_recent, string');
#
#$latest_gi = $query->get_recent(27478738);
#is($latest_gi, 42659163, 'get_recent, integer');
#
## check that default type is "gi"
#ok $query = Bio::DB::SeqVersion->new();
#ok my $ref = $query->get_history(3245);
#is($ref->[0]->[0], 578167, 'get_history');
is($latest_gi, 2, 'get_recent');

my @all_gis = $query->get_all(2);
cmp_ok(@all_gis, '>=', 8, 'get_all');

$latest_gi = $query->get_recent('A00002');
is($latest_gi, 2, 'get_recent, string');

$latest_gi = $query->get_recent(27478738);
is($latest_gi, 42659163, 'get_recent, integer');

# check that default type is "gi"
ok $query = Bio::DB::SeqVersion->new();
ok my $ref = $query->get_history(3245);
is($ref->[0]->[0], 578167, 'get_history');
}

done_testing();

0 comments on commit 48bf5f6

Please sign in to comment.