Changeset 23 for trunk


Ignore:
Timestamp:
09/28/05 21:55:53 (19 years ago)
Author:
thauvin
Message:
  • check obs really exists when getting value
Location:
trunk/soft/ObsData
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/soft/ObsData/ObsData.pm

    • Property cvs2svn:cvs-rev changed from 1.3 to 1.4
    r22 r23  
    4848} 
    4949 
     50sub is_obs { 
     51    my ($self, $obs) = @_; 
     52    grep { $_ eq "Obs $obs" } $self->{config}->GroupMembers('Obs'); 
     53} 
     54 
    5055sub list_datadir { 
    5156    my ($self, $obs) = @_; 
    52     $self->{config}->SectionExists($obs) or return undef; 
     57    $self->is_obs($obs) or return undef; 
    5358    map { m,^datadir/(.*),; ( $1 => $self->{config}->val($obs, $_) ) } 
    5459        grep { m,^datadir/, }  
     
    5661} 
    5762 
     63sub get_datadir { 
     64    my ($self, $obs, $type) = @_; 
     65    $self->is_obs($obs) or return undef; 
     66    $self->getvalue($obs, "datadir/$type"); 
     67} 
     68 
    58691; 
  • trunk/soft/ObsData/t/O-01.t

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r21 r23  
    11# $Id$ 
    22 
    3 use Test::More tests => 3; 
     3use Test::More tests => 4; 
    44 
    55use_ok('ObsData'); 
    66 
    7 # can_ok('ObsData', qw()); 
     7can_ok('ObsData', qw(list_obs list_datadir get_datadir getvalue is_obs)); 
    88 
    99ok(ObsData->new('testdata/obsdata-conftest'), "Can create object"); 
  • trunk/soft/ObsData/t/O-02.t

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r22 r23  
    11# $Id$ 
    22 
    3 use Test::More tests => 5; 
     3use Test::More tests => 8; 
    44 
    55use_ok('ObsData'); 
     
    99 
    1010ok(grep { 'ohp' } $o->list_obs, "Can list observatories"); 
     11 
     12ok($o->is_obs('ohp'), "check is an obs is defined"); 
     13ok(!$o->is_obs('NOohp'), "check is an obs is not defined"); 
     14 
    1115my %datadir =  $o->list_datadir('ohp'); 
    12 ok($datadir{ozone} = 'testdata/ohp/ozone', "Can get list of data directory"); 
     16ok($datadir{ozone} eq 'testdata/ohp/ozone', "Can get list of data directory"); 
     17ok($o->get_datadir('ohp', 'ozone') eq 'testdata/ohp/ozone', 'Can retrive data directory'); 
Note: See TracChangeset for help on using the changeset viewer.