[libcatmandu-marc-perl] 05/26: Rewriting aleph sequential tests

Jonas Smedegaard dr at jones.dk
Tue Dec 19 12:17:03 UTC 2017


This is an automated email from the git hooks/post-receive script.

js pushed a commit to annotated tag upstream/1.23.1
in repository libcatmandu-marc-perl.

commit d8a228c50b3436e0fc905fff1e757f0141d7f0e7
Author: Patrick Hochstenbach <patrick.hochstenbach at ugent.be>
Date:   Fri Nov 10 10:08:45 2017 +0100

    Rewriting aleph sequential tests
---
 t/Catmandu/Fix/Condition/marc_has.t | 18 ++++++++-
 t/Catmandu/Importer/MARC/ALEPHSEQ.t | 54 +++++++++++++++++++------
 t/old-new-internal-syntax.t         | 11 +-----
 t/rug01.aleph                       | 79 ++++++-------------------------------
 4 files changed, 72 insertions(+), 90 deletions(-)

diff --git a/t/Catmandu/Fix/Condition/marc_has.t b/t/Catmandu/Fix/Condition/marc_has.t
index db5335e..afef65f 100644
--- a/t/Catmandu/Fix/Condition/marc_has.t
+++ b/t/Catmandu/Fix/Condition/marc_has.t
@@ -39,8 +39,22 @@ unless marc_has_many(100a)
 end
 EOF
 
+my $record =<<'EOF';
+000000002 FMT   L BK
+000000002 LDR   L 00000nam^a2200301^i^4500
+000000002 001   L 000000002
+000000002 1001  L $$aMusterman
+000000002 24510 L $$aCatmandu Test
+000000002 650 0 L $$aPerl
+000000002 650 0 L $$aMARC$$aMARC2
+000000002 650 0 L $$a加德滿都
+000000002 920 0 L $$ablue$$ared
+000000002 CAT 0 L $$atest
+000000002 CAT 0 L $$atest
+EOF
+
 my $fixer = Catmandu::Fix->new(fixes => [$fixes]);
-my $importer = Catmandu::Importer::MARC->new( file => 't/rug01.aleph', type => "ALEPHSEQ" );
+my $importer = Catmandu::Importer::MARC->new( file => \$record, type => "ALEPHSEQ" );
 my $records = $fixer->fix($importer)->to_array;
 
 my $errors = $records->[0]->{test};
@@ -50,6 +64,6 @@ is_deeply $errors , [
         'has many CAT' ,
         'has many 920a' ,
         'has not more than one 100a' ,
-];
+] , 'got the expected results';
 
 done_testing;
diff --git a/t/Catmandu/Importer/MARC/ALEPHSEQ.t b/t/Catmandu/Importer/MARC/ALEPHSEQ.t
index 6a33f02..767ebdb 100644
--- a/t/Catmandu/Importer/MARC/ALEPHSEQ.t
+++ b/t/Catmandu/Importer/MARC/ALEPHSEQ.t
@@ -5,6 +5,7 @@ use warnings;
 use Test::More;
 use Test::Exception;
 use Catmandu::Importer::MARC;
+use utf8;
 
 my $pkg;
 
@@ -15,22 +16,53 @@ BEGIN {
 
 require_ok $pkg;
 
-my $importer = Catmandu::Importer::MARC->new( file => 't/rug01.aleph', type => "ALEPHSEQ" );
+my $record =<<'EOF';
+000000002 FMT   L BK
+000000002 LDR   L 00000nam^a2200301^i^4500
+000000002 001   L 000000002
+000000002 24510 L $$aCatmandu Test
+000000002 650 0 L $$aPerl
+000000002 650 0 L $$aMARC$$aMARC2
+000000002 650 0 L $$a加德滿都
+EOF
 
-ok $importer , 'got an MARC/ALEPHSEQ importer';
+my $expected = {
+    _id => '000000002',
+    record => [
+      [ 'FMT', ' ', ' ' , '_', 'BK' ] ,
+      [ 'LDR', ' ', ' ' , '_', '00000nam a2200301 i 4500' ] ,
+      [ '001', ' ', ' ' , '_', '000000002' ] ,
+      [ '245', '1', '0' , 'a', 'Catmandu Test' ] ,
+      [ '650', ' ', '0' , 'a', 'Perl' ] ,
+      [ '650', ' ', '0' , 'a', 'MARC' , 'a' , 'MARC2' ] ,
+      [ '650', ' ', '0' , 'a', '加德滿都' ] ,
+    ]
+};
 
-my @records;
+note("inline pasing");
+{
+    my $importer = Catmandu::Importer::MARC->new( file => \$record, type => "ALEPHSEQ" );
 
-my $n = $importer->each(
-    sub {
-        push( @records, $_[0] );
-    }
-);
+    ok $importer , 'got an MARC/ALEPHSEQ importer';
 
-ok(@records == 1);
+    my $result = $importer->first;
 
-ok($records[0]->{record}->[1]->[0] eq 'LDR');
+    ok $result , 'got a record';
 
-ok($records[0]->{record}->[1]->[-1] !~ /\^/);
+    is_deeply $result , $expected , 'got the expected result';
+}
+
+note("file pasing");
+{
+    my $importer = Catmandu::Importer::MARC->new( file => 't/rug01.aleph', type => "ALEPHSEQ" );
+
+    ok $importer , 'got an MARC/ALEPHSEQ importer';
+
+    my $results = $importer->to_array;
+
+    ok @$results == 2 , 'got two records';
+
+    is_deeply $results->[0] , $expected , 'got the expected result';
+}
 
 done_testing;
diff --git a/t/old-new-internal-syntax.t b/t/old-new-internal-syntax.t
index 08f123f..c003341 100644
--- a/t/old-new-internal-syntax.t
+++ b/t/old-new-internal-syntax.t
@@ -4,7 +4,7 @@ use warnings;
 use Catmandu::Importer::JSON;
 use Catmandu::Importer::MARC;
 
-use Test::More tests => 11;
+use Test::More tests => 8;
 
 my $fixer = Catmandu::Fix->new(fixes => ['marc_map("245a","title"); marc_map("500a","test")']);
 my $importer = Catmandu::Importer::JSON->new( file => 't/old_new.json' );
@@ -23,17 +23,10 @@ ok(defined($records->[0]->{title}), "1 has title");
 is($records->[0]->{title},'ActivePerl with ASP and ADO /',"0 has correct title");
 ok(&f245_contains_no_underscore($records->[0]),"MARC importer using the new syntax");
 
-$importer = Catmandu::Importer::MARC->new( file => 't/rug01.aleph' , type => "ALEPHSEQ");
-$records = $fixer->fix($importer)->to_array;
-
-ok(defined($records->[0]->{title}), "1 has title");
-is($records->[0]->{title},'Propositional structure and illocutionary force :',"0 has correct title");
-ok(&f245_contains_no_underscore($records->[0]),"MARC importer using the new syntax");
-
 sub f245_contains_no_underscore {
 	my $record = shift;
 	for (@{$record->{record}}) {
 		return 0 if ($_->[0] eq '245' && $_->[3] eq '_');
 	}
 	return 1;
-}
\ No newline at end of file
+}
diff --git a/t/rug01.aleph b/t/rug01.aleph
index db62bce..409a9c5 100644
--- a/t/rug01.aleph
+++ b/t/rug01.aleph
@@ -1,71 +1,14 @@
 000000002 FMT   L BK
 000000002 LDR   L 00000nam^a2200301^i^4500
 000000002 001   L 000000002
-000000002 005   L 20060108100247.0
-000000002 008   L 780804s1977^^^^enk^^^^^^b^^^^001^0^eng^^
-000000002 010   L $$a78307846
-000000002 015   L $$aGB***
-000000002 020   L $$a0855275103 :$$c13.50
-000000002 035   L $$9(DLC) 78307846
-000000002 040   L $$aDLC$$cDLC$$dDLC
-000000002 05000 L $$aP325$$b.K34 1977b
-000000002 08200 L $$a415
-000000002 1001  L $$aKatz, Jerrold J.
-000000002 24510 L $$aPropositional structure and illocutionary force :$$ba study of the contribution of sentence meaning to speech acts /$$cJerrold J. Katz.
-000000002 260   L $$aHassocks :$$bHarvester press,$$c1977.
-000000002 300   L $$axv, 249 p. ;$$c25 cm.
-000000002 4900  L $$aThe Language and thought series
-000000002 504   L $$aIncludes bibliographical references and index.
-000000002 650 0 L $$aSemantics.
-000000002 650 0 L $$aProposition (Logic)
-000000002 650 0 L $$aSpeech acts (Linguistics)
-000000002 650 0 L $$aGenerative grammar.
-000000002 650 0 L $$aCompetence and performance (Linguistics)
-000000002 920   L $$abook$$abla
-000000002 SID   L $$aZ39$$bLOC
-000000002 CAT   L $$a$$b00$$c19970601$$lRUG01$$h0958
-000000002 CAT   L $$a$$b00$$c19961224$$lRUG01$$h1724
-000000002 CAT   L $$a$$b00$$c19990325$$lRUG01$$h1346
-000000002 CAT   L $$a$$b$$c19990326$$lRUG01$$h1900
-000000002 CAT   L $$a$$b$$c19990507$$lRUG01$$h0500
-000000002 CAT   L $$a$$b$$c19990923$$lRUG01$$h1200
-000000002 CAT   L $$a$$b00$$c19990924$$lRUG01$$h0849
-000000002 CAT   L $$a$$b$$c19991129$$lRUG01$$h1723
-000000002 CAT   L $$c20000107$$lRUG01$$h1725
-000000002 CAT   L $$c20000114$$lRUG01$$h1836
-000000002 CAT   L $$c20000529$$lRUG01$$h1845
-000000002 CAT   L $$c20000711$$lRUG01$$h1200
-000000002 CAT   L $$c20000731$$lRUG01$$h2006
-000000002 CAT   L $$c20000828$$lRUG01$$h1700
-000000002 CAT   L $$c20000828$$lRUG01$$h1800
-000000002 CAT   L $$c20001004$$lRUG01$$h1839
-000000002 CAT   L $$c20001004$$lRUG01$$h2006
-000000002 CAT   L $$c20001005$$lRUG01$$h1309
-000000002 CAT   L $$c20001005$$lRUG01$$h2000
-000000002 CAT   L $$c20001006$$lRUG01$$h0500
-000000002 CAT   L $$c20010427$$lRUG01$$h1549
-000000002 CAT   L $$c20020608$$lRUG01$$h2215
-000000002 CAT   L $$c20021129$$lRUG01$$h0000
-000000002 CAT   L $$aFVDPITTE$$b20$$c20030702$$lRUG01$$h1115
-000000002 CAT   L $$c20030702$$lRUG01$$h2200
-000000002 CAT   L $$aUPGRADE$$b$$c20050826$$lRUG01$$h2001
-000000002 CAT   L $$c20050829$$lRUG01$$h1146
-000000002 CAT   L $$aFVDPITTE$$b20$$c20050904$$lRUG01$$h2047
-000000002 CAT   L $$c20050910$$lRUG01$$h1823
-000000002 CAT   L $$c20050911$$lRUG01$$h1100
-000000002 CAT   L $$aGDVREEZE$$b20$$c20050913$$lRUG01$$h0746
-000000002 CAT   L $$c20050917$$lRUG01$$h2146
-000000002 CAT   L $$aGDVREEZE$$b20$$c20060108$$lRUG01$$h1002
-000000002 CAT   L $$c20060914$$lRUG01$$h2200
-000000002 CAT   L $$c20060930$$lRUG01$$h2005
-000000002 CAT   L $$c20070120$$lRUG01$$h1426
-000000002 CAT   L $$c20080806$$lRUG01$$h0940
-000000002 CAT   L $$c20090117$$lRUG01$$h2259
-000000002 8524  L $$bLW01$$cL27$$jL27.18M201$$4Dept. LW01$$5L27
-000000002 8524  L $$bLW06$$cL18$$jL18.L010F128$$4Dept. LW06$$5L18
-000000002 8524  L $$bLW11$$cL33$$jL33.D01.006.063$$4Dept. LW11$$5L33
-000000002 8524  L $$bLW09$$cL17$$jL17.XIX02.01.242C$$4Dept. LW09$$5L17
-000000002 Z30-1 L $$lRUG01$$LRUG01$$mBOOK$$1LW01$$ADept. LW01$$2L27$$BL27$$3L27.18M201$$5000010206368$$819870213$$f02$$FLOAN/openkast
-000000002 Z30-1 L $$lRUG01$$LRUG01$$mBOOK$$1LW06$$ADept. LW06$$2L18$$BL18$$3L18.L010F128$$5902-20$$819970730$$f02$$FLOAN/openkast
-000000002 Z30-1 L $$lRUG01$$LRUG01$$mBOOK$$1LW09$$ADept. LW09$$2L17$$BL17$$3L17.XIX02.01.242C$$5000010400338$$820070820$$f02$$FLOAN/openkast
-000000002 Z30-1 L $$lRUG01$$LRUG01$$mBOOK$$1LW11$$ADept. LW11$$2L33$$BL33$$3L33.D01.006.063$$5000010184913$$820061023$$f02$$FLOAN/openkast
+000000002 24510 L $$aCatmandu Test
+000000002 650 0 L $$aPerl
+000000002 650 0 L $$aMARC$$aMARC2
+000000002 650 0 L $$a加德滿都
+000000003 FMT   L BK
+000000003 LDR   L 00000nam^a2200301^i^4500
+000000003 001   L 000000003
+000000003 24510 L $$aCatmandu Test
+000000003 650 0 L $$aPerl
+000000003 650 0 L $$aMARC$$aMARC2
+000000003 650 0 L $$a加德滿都

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libcatmandu-marc-perl.git



More information about the Pkg-perl-cvs-commits mailing list