fetch tests
authorDobrica Pavlinusic <dpavlin@rot13.org>
Fri, 31 Dec 2004 00:46:33 +0000 (00:46 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Fri, 31 Dec 2004 00:46:33 +0000 (00:46 +0000)
git-svn-id: file:///home/dpavlin/svn/Biblio-Isis/trunk@21 4670fa4d-42ec-0310-ab5b-a66af6943492

t/002_isis.t

index 4290505..7fc00c7 100755 (executable)
@@ -5,7 +5,7 @@ use blib;
 
 use Data::Dumper;
 
-use Test::More tests => 28;
+use Test::More tests => 94;
 
 BEGIN { use_ok( 'IsisDB' ); }
 
@@ -13,6 +13,8 @@ my $isis;
 
 sub test_data {
 
+       my $args = {@_};
+
        isa_ok ($isis, 'IsisDB');
 
        cmp_ok($isis->{maxmfn}, '==', 5, "maxmfn set to 5");
@@ -56,6 +58,53 @@ sub test_data {
                }
        }
 
+       # test fetch
+
+       my $data = [ {
+               '801' => [ '^aFFZG' ],
+               '702' => [ '^aHolder^bElizabeth' ],
+               '990' => [ '2140', '88', 'HAY' ],
+               '675' => [ '^a159.9' ],
+               '210' => [ '^aNew York^cNew York University press^dcop. 1988' ],
+       }, {
+               '210' => [ '^aNew York^cUniversity press^d1989' ],
+               '700' => [ '^aFrosh^bStephen' ],
+               '990' => [ '2140', '89', 'FRO' ],
+               '200' => [ '^aPsychoanalysis and psychology^eminding the gap^fStephen Frosh' ],
+               '215' => [ '^aIX, 275 str.^d23 cm' ],
+       }, {
+               '210' => [ '^aLondon^cFree Associoation Books^d1992' ],
+               '700' => [ '^aTurkle^bShirlie' ],
+               '990' => [ '2140', '92', 'LAC' ],
+               '200' => [ '^aPsychoanalitic politics^eJacques Lacan and Freud\'s French Revolution^fSherry Turkle' ],
+               '686' => [ '^a2140', '^a2140' ],
+       
+       }, {
+               '700' => [ '^aGross^bRichard' ],
+               '200' => [ '^aKey studies in psychology^fRichard D. Gross' ],
+               '210' => [ '^aLondon^cHodder & Stoughton^d1994' ],
+               '10' => [ '^a0-340-59691-0' ],
+       }, {
+               # identifier test
+               '225' => [ '1#^aMcGraw-Hill series in Psychology' ],
+               '200' => [ '1#^aPsychology^fCamille B. Wortman, Elizabeth F. Loftus, Mary E. Marshal' ],
+       } ];
+               
+       for (my $mfn = 1; $mfn <= $isis->{'maxmfn'}; $mfn++) {
+               my $rec;
+               ok($rec = $isis->fetch($mfn), "fetch $mfn");
+
+               foreach my $f (keys %{$data->[$mfn-1]}) {
+                       my $i = 0;
+                       foreach my $v (@{$data->[$mfn-1]->{$f}}) {
+                               $v =~ s/^[01# ][01# ]// if ($args->{no_ident});
+                               cmp_ok($rec->{$f}->[$i], '==', $v, "MFN $mfn $f:$i $v");
+                               $i++;
+                       }
+               }
+#              print Dumper($rec);
+       }
+
 }
 
 $isis = IsisDB->new (
@@ -64,10 +113,10 @@ $isis = IsisDB->new (
 
 print Dumper($isis);
 
-test_data;
+test_data( no_ident => 1 );
 
 $isis = IsisDB->new (
        isisdb => './data/isismarc/BIBL',
 );
 
-test_data;
+test_data();