Bugzilla – Attachment 98896 Details for
Bug 24531
OAI-PMH set mappings only consider first field with a given tag
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24531 - Test for OAI-PMH sets and repeated fields
Bug-24531---Test-for-OAI-PMH-sets-and-repeated-fie.patch (text/plain), 3.34 KB, created by
Magnus Enger
on 2020-02-14 07:52:23 UTC
(
hide
)
Description:
Bug 24531 - Test for OAI-PMH sets and repeated fields
Filename:
MIME Type:
Creator:
Magnus Enger
Created:
2020-02-14 07:52:23 UTC
Size:
3.34 KB
patch
obsolete
>From 37a722e40bdc4e6fdd732b0e7ea4e838f1dd9696 Mon Sep 17 00:00:00 2001 >From: Magnus Enger <magnus@libriotech.no> >Date: Wed, 29 Jan 2020 23:56:32 +0100 >Subject: [PATCH] Bug 24531 - Test for OAI-PMH sets and repeated fields > >This patch adds two tests related to OAI-PMH sets. It creates a >dummy record with a repeated field, with different values. It then >tests if the record is caught by mappings that match the value in >the first field, and then if it is caught by mappings that match >the second field. > >Signed-off-by: David Nind <david@davidnind.com> >--- > t/db_dependent/OAI/Sets.t | 73 ++++++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 72 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/OAI/Sets.t b/t/db_dependent/OAI/Sets.t >index f68552613f..6bc08dac13 100644 >--- a/t/db_dependent/OAI/Sets.t >+++ b/t/db_dependent/OAI/Sets.t >@@ -18,7 +18,7 @@ > > use Modern::Perl; > >-use Test::More tests => 144; >+use Test::More tests => 147; > use Test::MockModule; > use Test::Warn; > use MARC::Record; >@@ -587,4 +587,75 @@ UpdateOAISetsBiblio($biblionumberNotVH, $record); > my @setsNotEq = CalcOAISetsBiblio($record); > is_deeply(@setsNotEq, $setNotVH_id, 'The $record only belongs to $setNotVH'); > >+# ---------- Testing CalcOAISetsBiblio with repeated field ---------- >+ >+# Delete all existing sets to avoid false positives >+my $all_sets = GetOAISets; >+foreach my $set ( @$all_sets ) { >+ DelOAISet( $set->{'id'} ); >+} >+ >+# Create a MARC record with a repeated field 374 >+my $record_rep = MARC::Record->new; >+$record_rep->add_fields( >+ [ '001', '1234' ], >+ [ '100', ' ', ' ', a => 'N., N.' ], >+ [ '374', ' ', ' ', a => 'A' ], >+ [ '374', ' ', ' ', a => 'B', a => 'C' ] >+); >+ >+# Create a set >+my $setRep = { >+ 'spec' => 'Set where 374a equals a given letter', >+ 'name' => 'Rep' >+}; >+my $setRep_id = AddOAISet($setRep); >+# Create a mapping : 374$a should be "A" >+my $mappingRepA = [ >+ { >+ marcfield => '374', >+ marcsubfield => 'a', >+ operator => 'equal', >+ marcvalue => 'A', >+ }, >+]; >+# Add the mapping to the set >+ModOAISetMappings($setRep_id, $mappingRepA); >+ >+# Get a list of set ids the record belongs to >+my @setsRepA = CalcOAISetsBiblio($record_rep); >+is_deeply(\@setsRepA, [$setRep_id], 'The $record belongs to $setRep_id (matching on first field, first subfield)'); >+ >+# Create another mapping : 374$a should now be "B" >+my $mappingRepB = [ >+ { >+ marcfield => '374', >+ marcsubfield => 'a', >+ operator => 'equal', >+ marcvalue => 'B', >+ }, >+]; >+# Replace the first mapping with the second one >+ModOAISetMappings($setRep_id, $mappingRepB); >+ >+# Get a list of set ids the record belongs to >+my @setsRepB = CalcOAISetsBiblio($record_rep); >+is_deeply(\@setsRepB, [$setRep_id], 'The $record belongs to $setRep_id (matching on second field, first subfield)'); >+ >+# Create another mapping : 374$a should now be "C" >+my $mappingRepC = [ >+ { >+ marcfield => '374', >+ marcsubfield => 'a', >+ operator => 'equal', >+ marcvalue => 'C', >+ }, >+]; >+# Replace the first mapping with the second one >+ModOAISetMappings($setRep_id, $mappingRepC); >+ >+# Get a list of set ids the record belongs to >+my @setsRepC = CalcOAISetsBiblio($record_rep); >+is_deeply(\@setsRepC, [$setRep_id], 'The $record belongs to $setRep_id (matching on second field, second subfield)'); >+ > $schema->storage->txn_rollback; >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 24531
:
98153
|
98154
|
98221
|
98222
|
98894
|
98895
|
98896
|
98897
|
98906
|
98907