Bug 15108: (followup) OAI-PMH provider improvements
authorEre Maijala <ere.maijala@helsinki.fi>
Thu, 23 Feb 2017 12:44:09 +0000 (14:44 +0200)
committerKyle M Hall <kyle@bywatersolutions.com>
Mon, 8 May 2017 13:27:20 +0000 (09:27 -0400)
Fixed OAI-PMH Server tests to delete any existing issues before deleting biblios,
to delete oai_sets to avoid sets in the responses and to work with UNIMARC and
NORMARC as well as MARC21.

Signed-off-by: Olli-Antti Kivilahti <olli-antti.kivilahti@jns.fi>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

t/db_dependent/OAI/Server.t

index 4e1215c..1aa7fc1 100644 (file)
@@ -59,10 +59,12 @@ $schema->storage->txn_begin;
 my $dbh = C4::Context->dbh;
 
 $dbh->do("SET time_zone='+00:00'");
+$dbh->do('DELETE FROM issues');
 $dbh->do('DELETE FROM biblio');
 $dbh->do('DELETE FROM deletedbiblio');
 $dbh->do('DELETE FROM deletedbiblioitems');
 $dbh->do('DELETE FROM deleteditems');
+$dbh->do('DELETE FROM oai_sets');
 
 my $date_added = DateTime->now() . 'Z';
 my $date_to = substr($date_added, 0, 10) . 'T23:59:59Z';
@@ -72,7 +74,13 @@ my $sth = $dbh->prepare('SELECT timestamp FROM biblioitems WHERE biblionumber=?'
 # Add biblio records
 foreach my $index ( 0 .. NUMBER_OF_MARC_RECORDS - 1 ) {
     my $record = MARC::Record->new();
-    $record->append_fields( MARC::Field->new('245', '', '', 'a' => "Title $index" ) );
+    if (C4::Context->preference('marcflavour') eq 'UNIMARC') {
+        $record->append_fields( MARC::Field->new('101', '', '', 'a' => "lng" ) );
+        $record->append_fields( MARC::Field->new('200', '', '', 'a' => "Title $index" ) );
+    } else {
+        $record->append_fields( MARC::Field->new('008', '                                   lng' ) );
+        $record->append_fields( MARC::Field->new('245', '', '', 'a' => "Title $index" ) );
+    }
     my ($biblionumber) = AddBiblio($record, '');
     $sth->execute($biblionumber);
     my $timestamp = $sth->fetchrow_array . 'Z';
@@ -86,7 +94,7 @@ foreach my $index ( 0 .. NUMBER_OF_MARC_RECORDS - 1 ) {
         metadata => {
             'oai_dc:dc' => {
                 'dc:title' => "Title $index",
-                'dc:language' => {},
+                'dc:language' => "lng",
                 'dc:type' => {},
                 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
                 'xmlns:oai_dc' => 'http://www.openarchives.org/OAI/2.0/oai_dc/',