r600@llin: dpavlin | 2006-05-13 13:07:16 +0200
authorDobrica Pavlinusic <dpavlin@rot13.org>
Sat, 13 May 2006 12:07:27 +0000 (12:07 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sat, 13 May 2006 12:07:27 +0000 (12:07 +0000)
 added WebPAC::Normalize::Set to unit tests

git-svn-id: svn+ssh://mjesec/home/dpavlin/svn/webpac2/trunk@470 07558da8-63fa-0310-ba24-9fe276d99e06

t/6-unit.t
t/data/normalize.pl [new file with mode: 0755]
t/data/normalize.xml

index 1a30127..3ed0af6 100755 (executable)
@@ -2,32 +2,39 @@
 
 use strict;
 
-use Test::More tests => 34;
+use Test::More tests => 66;
 use Test::Exception;
 use Cwd qw/abs_path/;
 use File::Temp qw/tempdir/;
+use File::Slurp;
 use Data::Dumper;
 use blib;
 
+my $debug = 1;
+
 BEGIN {
 use_ok( 'WebPAC::Lookup' );
 use_ok( 'WebPAC::Input' );
 use_ok( 'WebPAC::Store' );
 use_ok( 'WebPAC::Normalize::XML' );
+use_ok( 'WebPAC::Normalize::Set' );
 use_ok( 'WebPAC::Output::TT' );
 }
 
 ok(my $abs_path = abs_path($0), "abs_path");
 $abs_path =~ s#/[^/]*$#/#;
-diag "abs_path: $abs_path";
+diag "abs_path: $abs_path" if ($debug);
 
 my $isis_file = "$abs_path../t/winisis/BIBL";
 $isis_file = '/data/hidra/THS/THS';
 
-diag "isis_file: $isis_file";
+diag "isis_file: $isis_file" if ($debug);
+
+my $normalize_set_pl = "$abs_path/data/normalize.pl";
+my $lookup_file = "$abs_path../conf/lookup/isis.pm";
 
 ok(my $lookup = new WebPAC::Lookup(
-       lookup_file => "$abs_path../conf/lookup/isis.pm",
+       lookup_file => $lookup_file,
 ), "new Lookup");
 
 ok(my $isis = new WebPAC::Input(
@@ -61,16 +68,35 @@ ok($n->open(
        xml_file => "$abs_path/data/normalize.xml",
 ), "Normalize::XML->open");
 
+ok(my $norm_pl = read_file( $normalize_set_pl ), "set definitions: $normalize_set_pl" );
+
 ok(my $out = new WebPAC::Output::TT(
        include_path => "$abs_path../conf/output/tt",
        filters => { foo => sub { shift } },
 ), "new Output::TT");
 
 while (my $row = $isis->fetch) {
-       
+
        ok(my $ds = $n->data_structure($row), "data_structure");
 
-#      diag Dumper($ds);
+       diag " ds => ",Dumper($ds) if ($debug);
+
+       # TODO move somewhere
+       {
+               no strict 'subs';
+               use WebPAC::Normalize::Set;
+               diag " row => ",Dumper($row) if ($debug);
+               set_rec( $row );
+               #diag " lookup => ",Dumper($lookup) if ($debug);
+               #set_lookup( $lookup );
+               clean_ds();
+               eval "$norm_pl";
+               ok(! $@, $@ ? "error: $@" : "no error");
+               ok(my $ds2 = get_ds(), "get_ds");
+               is_deeply( $ds, $ds2, 'ds same for xml and sets');
+
+               diag " ds2 => ",Dumper($ds2) if ($debug);
+       }
 
        ok(my $html = $out->apply(
                template => 'html.tt',
diff --git a/t/data/normalize.pl b/t/data/normalize.pl
new file mode 100755 (executable)
index 0000000..ad5667c
--- /dev/null
@@ -0,0 +1,319 @@
+tag('MFN',
+       rec('000')
+);
+
+display('ISBN',
+       rec('10')
+);
+
+display('ISSN',
+       rec('11')
+);
+
+search('ISN',
+       rec('10'),
+       rec('11'),
+);
+
+tag('Language',
+       rec('101')
+);
+
+tag('TitleProper',
+       regex( 's/<[^>]*>//g',
+               rec('200','a')
+       )
+);
+
+tag('titleNo',
+       rec('200','9')
+);
+
+tag('Subtitle',
+       rec('200','e')
+);
+
+tag('TitleProper2',
+       rec('200','c')
+);
+
+tag('ParallelTitle',
+       rec('200','d')
+);
+
+tag('Responsibility',
+       join_with(" ; ",
+               rec('200','f'),
+               rec('200','g')
+       )
+);
+
+tag('VolumeDesignation',
+       rec('200','v')
+);
+
+tag('EditionStatement',
+       rec('205','a')
+);
+
+tag('SerialNo',
+       rec('207','a')
+);
+
+tag('fond',
+       rec('209','a')
+);
+
+tag('PlacePublication',
+       rec('210','a')
+);
+
+tag('NamePublisher',
+       rec('210','c')
+);
+
+tag('DatePublication',
+       rec('210','d')
+);
+
+tag('PhysicalDescription',
+       join_with(" : ",
+               rec('215','a'),
+               join_with(" ; ",
+                       rec('215','c'),
+                       rec('215','d'),
+               )
+       )
+);
+
+tag('MaterialDesignation',
+       rec('215','a')
+);
+
+tag('PhysicalDetails',
+       rec('215','c')
+);
+
+tag('AccompanyingMaterial',
+       rec('215','e')
+);
+
+tag('Series',
+       join_with(" = ", rec('225','a'),
+               join_with(" : ", rec('225','d'),
+                       join_with(" ; ", rec('225','e'),
+                               join_with(". ", rec('225','v'),
+                                       join_with(", ", rec('225','h'),
+                                               join_with(" ; ", rec('225','i'),
+                                                       rec('225','w'),
+                                               )
+                                       )
+                               )
+                       )
+               )
+       )
+);
+
+tag('SeriesTitle',
+       rec('225','a')
+);
+
+tag('GeneralNote',
+       rec('300')
+);
+
+tag('EditionNote',
+       rec('305')
+);
+
+tag('PhysicalDescriptionNote',
+       rec('307')
+);
+
+tag('IntellectResponsNote',
+       rec('314')
+);
+
+tag('InternalBibliographies',
+       rec('320')
+);
+
+tag('Frequency',
+       rec('326')
+);
+
+tag('ContentsNote',
+       rec('327')
+);
+
+tag('Summary',
+       rec('330')
+);
+
+tag('SystemRequirements',
+       rec('337')
+);
+
+tag('IssuedWith',
+       join_with(': ', rec(423,'z'),
+               join_with(' / ', rec(423,'a'),
+                       join_with(' ', rec(423,'c'),
+                               rec(423,'b')
+                       )
+               )
+       )
+);
+
+display('Parts',
+       lookup(
+               prefix( 'dio-jzav:', rec(900) )
+       )
+);
+
+search('Parts',
+       lookup(
+               prefix( 'id-dio-jzav:', rec(900) )
+       )
+);
+
+display('PartsEF',
+       lookup(
+               prefix( 'naslov-efzg:001', rec('001') )
+       )
+);
+
+tag('PartsID',
+       rec('463','1')
+);
+
+tag('Piece',
+       lookup(
+               prefix( 'naslov-efzg:',
+                       first(
+                               rec(463,1)
+                       )
+               )
+       )
+);
+
+tag('PieceSubtitle',
+       lookup(
+               prefix( 'podnaslov-efzg:',
+                       first(
+                               rec(463,1)
+                       )
+               )
+       )
+);
+
+tag('PieceNum',
+       rec('463','v')
+);
+
+tag('PieceAnalitic',
+       join_with(' / ',
+               rec('464','a'),
+               join_with(' ',
+                       rec(464,'g'),
+                       rec(464,'f'),
+               )
+       )
+);
+
+tag('UniformHeading',
+       join_with('. ',
+               rec(500,'a'),
+               rec(500,'b'),
+       )
+);
+
+tag('ExpandedTitle',
+       rec(532)
+);
+
+tag('Form',
+       rec(608)
+);
+
+tag('UncontroledTerms',
+       rec(610)
+);
+
+tag('UDC',
+       rec(675)
+);
+
+tag('APACC',
+       rec(686)
+);
+
+tag('PersonalNamePrim',
+       join_with(', ',
+               rec(700,'a'),
+               rec(700,'b'),
+       )
+);
+
+tag('PersonalNameSec',
+       join_with(', ',
+               rec(701,'a'),
+               rec(701,'b'),
+       )
+);
+
+tag('PersonalNameOth',
+       join_with(', ',
+               rec(702,'a'),
+               rec(702,'b'),
+       )
+);
+
+search('Names',
+       rec(700),
+       rec(701),
+       rec(702),
+);
+
+tag('CorporateNamePrim',
+       join_with(', ',
+               rec(710,'a'),
+               rec(710,'b'),
+       )
+);
+
+tag('CorporateNameSec',
+       join_with(', ',
+               rec(711,'a'),
+               rec(711,'b'),
+       )
+);
+
+tag('OriginatingSource',
+       rec(801)
+);
+
+tag('URL',
+       rec(856,'u')
+);
+
+tag('level',
+       rec(909)
+);
+
+tag('ID',
+       rec(900)
+);
+
+tag('CallNo',
+       rec(990)
+);
+
+tag('InvNo',
+       rec(991)
+);
+
+       
+
+
+
+
index ebcb429..54383f1 100644 (file)
@@ -24,8 +24,7 @@
        </IdentificationNumbers>
        
        <Language>
-               <isis type="search">filter{lang_search}v101</isis>
-               <isis type="display">filter{lang_display}v101</isis>
+               <isis>v101</isis>
        </Language>
        
        <TitleProper>
@@ -49,7 +48,7 @@
        </ParallelTitle>
 
        <Responsibility>
-               <isis>v200^g v200^f</isis>
+               <isis>v200^f ; v200^g</isis>
        </Responsibility>
                
        <ResponsibilityFirst>
        <EditionStatement>
                <isis>v205^a</isis>
        </EditionStatement>
-       
+
+       <SerialNo>
+               <isis>v207^a</isis>
+       </SerialNo>
+
+       <fond>
+               <isis>v209^a</isis>
+       </fond>
+
        <PlacePublication>
                <isis>v210^a</isis>
        </PlacePublication>
                <isis>v314</isis>
        </IntellectResponsNote>
 
-       <InternalBiliographies>
+       <InternalBibliographies>
                <isis>v320</isis>
-       </InternalBiliographies>
+       </InternalBibliographies>
+
+       <Frequency>
+               <isis>v326</isis>
+       </Frequency>
 
        <ContentsNote>
                <isis>v327</isis>
        </IssuedWith>
 
        <Parts>
-               <isis>lookup{part:00v463^1}</isis>
+               <isis type="display">lookup{dio-jzav:v900}</isis>
+               <isis type="search">lookup{id-dio-jzav:v900}</isis>
        </Parts>
+       
+       <PartsEF>
+               <isis type="display">lookup{naslov-efzg:001v001}</isis>
+       </PartsEF>
 
        <PartsID>
                <isis>v463^1</isis>
        </PartsID>
 
+       <Piece>
+               <isis>lookup{naslov-efzg:s463^1}</isis>
+       </Piece>
+
+       <PieceSubtitle>
+               <isis>lookup{podnaslov-efzg:s463^1}</isis>
+       </PieceSubtitle>
+
+       <PieceNum>
+               <isis>v463^v</isis>
+       </PieceNum>
+       
+
        <PieceAnalitic>
                <isis>v464^a / v464^g v464^f</isis>
        </PieceAnalitic>
        </Form>
 
        <UncontrolledTerms>
-               <isis>v610^a</isis>     
+               <isis>v610</isis>       
        </UncontrolledTerms>
        
        <UDC_All>
                <isis>v675^a</isis>
        </UDC>
 
+       <UDCb>
+               <isis>v675^b</isis>
+       </UDCb>
+
        <APA>
                <isis>v686</isis>
        </APA>
                <isis>v856^u</isis>
        </URL>
 
-       <recType>
-               <isis>lookup{tip:v900}</isis>
-       </recType>
-
-       <Parts3>
-               <!--
-               <isis>lookup{naslov:lookup{tip-naslovi:v946^1}}</isis>
-               -->
-               <isis>lookup{naslov3:v900}</isis>
-       </Parts3>
+       <level>
+               <isis>v909</isis>
+       </level>
        
-       <Parts4>
-               <isis>lookup{naslov4:v900}</isis>
-       </Parts4>
+       <ID>
+               <isis>v900</isis>
+               <isis>001v001</isis>
+       </ID>
        
+       <Set>
+               <isis type="display">lookup{set-jzav:v946^1}</isis>
+               <isis type="search">v946^1</isis>
+               <isis type="display">lookup{set-efzg:v461^1}</isis>
+               <isis type="search">v461^1</isis>
+       </Set>
+
+       <Set2>
+               <isis>lookup{set-jzav:lookup{parent-id:v946^1}}</isis>
+       </Set2>
+
        <CallNo>
                <isis>v990</isis>
        </CallNo>
 
-       <LibraryLabel>
-               <isis><![CDATA[filter{regex(s/IZ/Informacijske znanosti/)}v994^a]]></isis>
-       </LibraryLabel>
-
        <InvNo>
                <isis>v991</isis>
        </InvNo>
 
-       <type name="Vrsta graðe: " order="100">
-               <!-- added via xml tag in .conf -->
-               <config type="display">materialtype</config>
-               <config type="search">material_code</config>
-               <isis type="search">v200^e</isis>
-       </type>
-       
-       <form name="Format: " order="101">
-               <!-- added via xml tag in .conf -->
-               <config type="search">material_form</config>
-       </form>
-       
-       <library name="Knji¾nica: " order="110">
-               <!-- added via library tag in .conf -->
-               <config type="display">library</config>
-               <config type="display" append="1" >
-                       <delimiter>, </delimiter>
-                       <value>library_url</value>
-               </config>
-               <config type="search">library_code</config>
-       </library>
-
 </indexer>
 </config>