Skip to content
Snippets Groups Projects
Commit 41e68982 authored by Jens Steidl's avatar Jens Steidl :baby_chick:
Browse files

- refactor: removed obsolete tests and variables

parent a1b70fa5
Branches main
No related tags found
No related merge requests found
......@@ -24,7 +24,7 @@ use strict;
use warnings;
use diagnostics;
use Test::More tests => 138;
use Test::More tests => 109;
use Test::Output;
use Test::Exception;
use Test::File;
......@@ -127,509 +127,10 @@ BEGIN {
require "slubsipbuilderbagit.pl";
$INC{'SLUB/LZA/SIPBuilderBagIt.pm'} = 1; # needed because inlined module
}
my $unpatched_mods=<<'UNPATCHED_MODS';
<?xml version="1.0" encoding="UTF-8"?>
<mods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.loc.gov/mods/v3" version="3.6" xsi:schemaLocation="http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-6.xsd"><titleInfo><nonSort xml:space="preserve">Der </nonSort><title>Fichtelberg</title><subTitle>Berg der unbekannten Rekorrde</subTitle></titleInfo><name type="personal"><namePart>Schneider, Dirk</namePart><role><roleTerm type="text">FilmemacherIn</roleTerm></role><role><roleTerm authority="marcrelator" type="code">fmk</roleTerm></role><nameIdentifier>(DE-627)1235502279 (DE-576)165502274</nameIdentifier></name><typeOfResource>moving image</typeOfResource><genre authority="rdacontent">zweidimensionales bewegtes Bild</genre><genre authority="gnd-content">Film</genre><originInfo><place><placeTerm type="code" authority="marccountry">xx</placeTerm></place><dateIssued encoding="marc">2014</dateIssued><issuance>monographic</issuance></originInfo><originInfo eventType="publication"><place><placeTerm type="text">[Leipzig]</placeTerm></place><publisher>top ten tv</publisher><dateIssued>[2014]</dateIssued></originInfo><language><languageTerm authority="iso639-2b" type="code">ger</languageTerm></language><physicalDescription><form authority="marccategory">electronic resource</form><form authority="marcsmd">remote</form><extent>1 Online-Ressource (1 Videodatei, 29:49) farbig</extent><form type="media" authority="rdamedia">Computermedien</form><form type="carrier" authority="rdacarrier">Online-Ressource</form></physicalDescription><targetAudience authority="marctarget">juvenile</targetAudience><note type="statement of responsibility" altRepGroup="00">ein Film von Dirk Schneider</note><note>Dokumentarfilm. Deutschland. 2014</note><relatedItem type="series"><titleInfo><title>MDR</title></titleInfo></relatedItem><relatedItem type="series"><titleInfo><title>Der Osten - entdecke wo du lebst</title></titleInfo></relatedItem><identifier type="oclc">946544758</identifier><recordInfo><descriptionStandard>rda</descriptionStandard><recordContentSource authority="marcorg">DE-576</recordContentSource><recordCreationDate encoding="marc">160304</recordCreationDate><recordChangeDate encoding="iso8601">20160510144338.0</recordChangeDate><recordIdentifier source="DE-576">457035137</recordIdentifier><recordOrigin>Converted from MARCXML to MODS version 3.6 using MARC21slim2MODS3-6.xsl
(Revision 1.119 2018/06/21)</recordOrigin><languageOfCataloging><languageTerm authority="iso639-2b" type="code">ger</languageTerm></languageOfCataloging></recordInfo></mods>
UNPATCHED_MODS
my $patched_mods=<<'PATCHED_MODS';
<?xml version="1.0" encoding="UTF-8"?>
<mods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.loc.gov/mods/v3" version="3.6" xsi:schemaLocation="http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-6.xsd"><titleInfo><nonSort xml:space="preserve">Der </nonSort><title>Fichtelberg</title><subTitle>Berg der unbekannten Rekorrde</subTitle></titleInfo><name type="personal"><namePart>Schneider, Dirk</namePart><role><roleTerm type="text">FilmemacherIn</roleTerm></role><role><roleTerm authority="marcrelator" type="code">fmk</roleTerm></role><nameIdentifier>(DE-627)1235502279 (DE-576)165502274</nameIdentifier></name><typeOfResource>moving image</typeOfResource><genre authority="rdacontent">zweidimensionales bewegtes Bild</genre><genre authority="gnd-content">Film</genre><originInfo><place><placeTerm type="code" authority="marccountry">xx</placeTerm></place><dateIssued encoding="marc">2014</dateIssued><issuance>monographic</issuance></originInfo><originInfo eventType="publication"><place><placeTerm type="text">[Leipzig]</placeTerm></place><publisher>top ten tv</publisher><dateIssued>[2014]</dateIssued></originInfo><language><languageTerm authority="iso639-2b" type="code">ger</languageTerm></language><physicalDescription><form authority="marccategory">electronic resource</form><form authority="marcsmd">remote</form><extent>1 Online-Ressource (1 Videodatei, 29:49) farbig</extent><form type="media" authority="rdamedia">Computermedien</form><form type="carrier" authority="rdacarrier">Online-Ressource</form></physicalDescription><targetAudience authority="marctarget">juvenile</targetAudience><note type="statement of responsibility" altRepGroup="00">ein Film von Dirk Schneider</note><note>Dokumentarfilm. Deutschland. 2014</note><relatedItem type="series"><titleInfo><title>MDR</title></titleInfo></relatedItem><relatedItem type="series"><titleInfo><title>Der Osten - entdecke wo du lebst</title></titleInfo></relatedItem><identifier type="oclc">946544758</identifier><recordInfo><descriptionStandard>rda</descriptionStandard><recordContentSource authority="marcorg">DE-576</recordContentSource><recordCreationDate encoding="marc">160304</recordCreationDate><recordChangeDate encoding="iso8601">20160510144338.0</recordChangeDate><recordIdentifier source="DE-576">457035137</recordIdentifier><recordOrigin>Converted from MARCXML to MODS version 3.6 using MARC21slim2MODS3-6.xsl
(Revision 1.119 2018/06/21)</recordOrigin><languageOfCataloging><languageTerm authority="iso639-2b" type="code">ger</languageTerm></languageOfCataloging></recordInfo></mods>
PATCHED_MODS
my $unpatched_mods_obj = XML::LibXML->load_xml(string => $unpatched_mods);
my $unpatched_marcblob=<<'UNPATCHED_MARCBLOB';
<?xml version="1.0"?>
<record xmlns="http://www.loc.gov/MARC21/slim">
<leader> cgm a22 4500</leader>
<controlfield tag="001">457035137</controlfield>
<controlfield tag="003">DE-576</controlfield>
<controlfield tag="005">20160510144338.0</controlfield>
<controlfield tag="006">m o | | </controlfield>
<controlfield tag="007">cr uuu---uuuuu</controlfield>
<controlfield tag="007">vu uuuuuu</controlfield>
<controlfield tag="008">160304s2014 xx ger c</controlfield>
<datafield tag="035" ind1=" " ind2=" ">
<subfield code="a">(DE-627)1655506501</subfield>
</datafield>
<datafield tag="035" ind1=" " ind2=" ">
<subfield code="a">(DE-576)457035137</subfield>
</datafield>
<datafield tag="035" ind1=" " ind2=" ">
<subfield code="a">(DE-599)BSZ457035137</subfield>
</datafield>
<datafield tag="035" ind1=" " ind2=" ">
<subfield code="a">(OCoLC)946544758</subfield>
</datafield>
<datafield tag="040" ind1=" " ind2=" ">
<subfield code="a">DE-576</subfield>
<subfield code="b">ger</subfield>
<subfield code="c">DE-576</subfield>
<subfield code="e">rda</subfield>
</datafield>
<datafield tag="041" ind1=" " ind2=" ">
<subfield code="a">ger</subfield>
</datafield>
<datafield tag="245" ind1="1" ind2="4">
<subfield code="a">Der Fichtelberg</subfield>
<subfield code="b">Berg der unbekannten Rekorrde</subfield>
<subfield code="c">ein Film von Dirk Schneider</subfield>
</datafield>
<datafield tag="264" ind1=" " ind2="1">
<subfield code="a">[Leipzig]</subfield>
<subfield code="b">top ten tv</subfield>
<subfield code="c">[2014]</subfield>
</datafield>
<datafield tag="264" ind1=" " ind2="4">
<subfield code="c">&#xA9; 2014</subfield>
</datafield>
<datafield tag="300" ind1=" " ind2=" ">
<subfield code="a">1 Online-Ressource (1 Videodatei, 29:49)</subfield>
<subfield code="b">farbig</subfield>
</datafield>
<datafield tag="336" ind1=" " ind2=" ">
<subfield code="a">zweidimensionales bewegtes Bild</subfield>
<subfield code="b">tdi</subfield>
<subfield code="2">rdacontent</subfield>
</datafield>
<datafield tag="337" ind1=" " ind2=" ">
<subfield code="a">Computermedien</subfield>
<subfield code="b">c</subfield>
<subfield code="2">rdamedia</subfield>
</datafield>
<datafield tag="338" ind1=" " ind2=" ">
<subfield code="a">Online-Ressource</subfield>
<subfield code="b">cr</subfield>
<subfield code="2">rdacarrier</subfield>
</datafield>
<datafield tag="490" ind1="0" ind2=" ">
<subfield code="a">MDR</subfield>
</datafield>
<datafield tag="490" ind1="0" ind2=" ">
<subfield code="a">Der Osten - entdecke wo du lebst</subfield>
</datafield>
<datafield tag="500" ind1=" " ind2=" ">
<subfield code="a">Dokumentarfilm. Deutschland. 2014</subfield>
</datafield>
<datafield tag="591" ind1=" " ind2=" ">
<subfield code="a">Fernsehmitschnitt (SWB)</subfield>
</datafield>
<datafield tag="655" ind1=" " ind2="7">
<subfield code="a">Film</subfield>
<subfield code="0">(DE-588)4017102-4</subfield>
<subfield code="0">(DE-627)104559683</subfield>
<subfield code="0">(DE-576)208918531</subfield>
<subfield code="2">gnd-content</subfield>
</datafield>
<datafield tag="700" ind1="1" ind2=" ">
<subfield code="a">Schneider, Dirk</subfield>
<subfield code="e">FilmemacherIn</subfield>
<subfield code="0">(DE-627)1235502279</subfield>
<subfield code="0">(DE-576)165502274</subfield>
<subfield code="4">fmk</subfield>
</datafield>
<datafield tag="935" ind1=" " ind2=" ">
<subfield code="c">vide</subfield>
</datafield>
<datafield tag="937" ind1=" " ind2=" ">
<subfield code="a">Dokumentarfilm</subfield>
<subfield code="b">Deutschland</subfield>
<subfield code="c">2014</subfield>
</datafield>
<datafield tag="LOK" ind1=" " ind2=" ">
<subfield code="0">000 xxxxxcx a22 zn 4500</subfield>
</datafield>
<datafield tag="LOK" ind1=" " ind2=" ">
<subfield code="0">001 901795887</subfield>
</datafield>
<datafield tag="LOK" ind1=" " ind2=" ">
<subfield code="0">003 DE-576</subfield>
</datafield>
<datafield tag="LOK" ind1=" " ind2=" ">
<subfield code="0">004 457035137</subfield>
</datafield>
<datafield tag="LOK" ind1=" " ind2=" ">
<subfield code="0">005 20160510125331</subfield>
</datafield>
<datafield tag="LOK" ind1=" " ind2=" ">
<subfield code="0">008 160304||||||||||||||||ger|||||||</subfield>
</datafield>
<datafield tag="LOK" ind1=" " ind2=" ">
<subfield code="0">040 </subfield>
<subfield code="a">DE-14</subfield>
<subfield code="c">DE-576</subfield>
<subfield code="d">DE-14</subfield>
</datafield>
<datafield tag="LOK" ind1=" " ind2=" ">
<subfield code="0">852 </subfield>
<subfield code="z">Fernsehmitschnitt: MDR, 04.02.2014. - Beilage</subfield>
</datafield>
<datafield tag="LOK" ind1=" " ind2=" ">
<subfield code="0">852 </subfield>
<subfield code="a">DE-14</subfield>
</datafield>
<datafield tag="LOK" ind1=" " ind2=" ">
<subfield code="0">852 1</subfield>
<subfield code="9">00</subfield>
</datafield>
<datafield tag="LOK" ind1=" " ind2=" ">
<subfield code="0">866 </subfield>
<subfield code="x">ddsu,pn</subfield>
</datafield>
</record>
UNPATCHED_MARCBLOB
my $patched_marcblob =<<'PATCHED_MARCBLOB';
<?xml version="1.0"?>
<record xmlns="http://www.loc.gov/MARC21/slim">
<leader> cgm a22 4500</leader>
<controlfield tag="001">457035137</controlfield>
<controlfield tag="003">DE-576</controlfield>
<controlfield tag="005">20160510144338.0</controlfield>
<controlfield tag="006">m o | | </controlfield>
<controlfield tag="007">cr uuu---uuuuu</controlfield>
<controlfield tag="007">vu uuuuuu</controlfield>
<controlfield tag="008">160304s2014 xx ger c</controlfield>
<datafield tag="035" ind1=" " ind2=" ">
<subfield code="a">(DE-627)1655506501</subfield>
</datafield>
<datafield tag="035" ind1=" " ind2=" ">
<subfield code="a">(DE-576)457035137</subfield>
</datafield>
<datafield tag="035" ind1=" " ind2=" ">
<subfield code="a">(DE-599)BSZ457035137</subfield>
</datafield>
<datafield tag="035" ind1=" " ind2=" ">
<subfield code="a">(OCoLC)946544758</subfield>
</datafield>
<datafield tag="040" ind1=" " ind2=" ">
<subfield code="a">DE-576</subfield>
<subfield code="b">ger</subfield>
<subfield code="c">DE-576</subfield>
<subfield code="e">rda</subfield>
</datafield>
<datafield tag="041" ind1=" " ind2=" ">
<subfield code="a">ger</subfield>
</datafield>
<datafield tag="245" ind1="1" ind2="4">
<subfield code="a">Der Fichtelberg</subfield>
<subfield code="b">Berg der unbekannten Rekorrde</subfield>
<subfield code="c">ein Film von Dirk Schneider</subfield>
</datafield>
<datafield tag="264" ind1=" " ind2="1">
<subfield code="a">[Leipzig]</subfield>
<subfield code="b">top ten tv</subfield>
<subfield code="c">[2014]</subfield>
</datafield>
<datafield tag="264" ind1=" " ind2="4">
<subfield code="c">&#xA9; 2014</subfield>
</datafield>
<datafield tag="300" ind1=" " ind2=" ">
<subfield code="a">1 Online-Ressource (1 Videodatei, 29:49)</subfield>
<subfield code="b">farbig</subfield>
</datafield>
<datafield tag="336" ind1=" " ind2=" ">
<subfield code="a">zweidimensionales bewegtes Bild</subfield>
<subfield code="b">tdi</subfield>
<subfield code="2">rdacontent</subfield>
</datafield>
<datafield tag="337" ind1=" " ind2=" ">
<subfield code="a">Computermedien</subfield>
<subfield code="b">c</subfield>
<subfield code="2">rdamedia</subfield>
</datafield>
<datafield tag="338" ind1=" " ind2=" ">
<subfield code="a">Online-Ressource</subfield>
<subfield code="b">cr</subfield>
<subfield code="2">rdacarrier</subfield>
</datafield>
<datafield tag="490" ind1="0" ind2=" ">
<subfield code="a">MDR</subfield>
</datafield>
<datafield tag="490" ind1="0" ind2=" ">
<subfield code="a">Der Osten - entdecke wo du lebst</subfield>
</datafield>
<datafield tag="500" ind1=" " ind2=" ">
<subfield code="a">Dokumentarfilm. Deutschland. 2014</subfield>
</datafield>
<datafield tag="591" ind1=" " ind2=" ">
<subfield code="a">Fernsehmitschnitt (SWB)</subfield>
</datafield>
<datafield tag="655" ind1=" " ind2="7">
<subfield code="a">Film</subfield>
<subfield code="0">(DE-588)4017102-4</subfield>
<subfield code="0">(DE-627)104559683</subfield>
<subfield code="0">(DE-576)208918531</subfield>
<subfield code="2">gnd-content</subfield>
</datafield>
<datafield tag="700" ind1="1" ind2=" ">
<subfield code="a">Schneider, Dirk</subfield>
<subfield code="e">FilmemacherIn</subfield>
<subfield code="0">(DE-627)1235502279</subfield>
<subfield code="0">(DE-576)165502274</subfield>
<subfield code="4">fmk</subfield>
</datafield>
<datafield tag="935" ind1=" " ind2=" ">
<subfield code="c">vide</subfield>
</datafield>
<datafield tag="937" ind1=" " ind2=" ">
<subfield code="a">Dokumentarfilm</subfield>
<subfield code="b">Deutschland</subfield>
<subfield code="c">2014</subfield>
</datafield>
<datafield tag="LOK" ind1=" " ind2=" ">
<subfield code="0">000 xxxxxcx a22 zn 4500</subfield>
</datafield>
<datafield tag="LOK" ind1=" " ind2=" ">
<subfield code="0">001 901795887</subfield>
</datafield>
<datafield tag="LOK" ind1=" " ind2=" ">
<subfield code="0">003 DE-576</subfield>
</datafield>
<datafield tag="LOK" ind1=" " ind2=" ">
<subfield code="0">004 457035137</subfield>
</datafield>
<datafield tag="LOK" ind1=" " ind2=" ">
<subfield code="0">005 20160510125331</subfield>
</datafield>
<datafield tag="LOK" ind1=" " ind2=" ">
<subfield code="0">008 160304||||||||||||||||ger|||||||</subfield>
</datafield>
<datafield tag="LOK" ind1=" " ind2=" ">
<subfield code="0">040 </subfield>
<subfield code="a">DE-14</subfield>
<subfield code="c">DE-576</subfield>
<subfield code="d">DE-14</subfield>
</datafield>
<datafield tag="LOK" ind1=" " ind2=" ">
<subfield code="0">852 </subfield>
<subfield code="z">Fernsehmitschnitt: MDR, 04.02.2014. - Beilage</subfield>
</datafield>
<datafield tag="LOK" ind1=" " ind2=" ">
<subfield code="0">852 </subfield>
<subfield code="a">DE-14</subfield>
</datafield>
<datafield tag="LOK" ind1=" " ind2=" ">
<subfield code="0">852 1</subfield>
<subfield code="9">00</subfield>
</datafield>
<datafield tag="LOK" ind1=" " ind2=" ">
<subfield code="0">866 </subfield>
<subfield code="x">ddsu,pn</subfield>
</datafield>
</record>
PATCHED_MARCBLOB
my $unpatched_marcblob_obj = XML::LibXML->load_xml(string => $unpatched_marcblob);
my $unpatched_marc21slimutils = <<'UNPATCHED_MARC21SLIMUTIL';
<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:marc="http://www.loc.gov/MARC21/slim"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- 08/08/08: tmee added corrected chopPunctuation templates for 260c -->
<!-- 08/19/04: ntra added "marc:" prefix to datafield element -->
<!-- 12/14/07: ntra added url encoding template -->
<!-- url encoding -->
<xsl:variable name="ascii">
<xsl:text> !"#$%&amp;'()*+,-./0123456789:;&lt;=&gt;?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~</xsl:text>
</xsl:variable>
<xsl:variable name="latin1">
<xsl:text> ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ</xsl:text>
</xsl:variable>
<!-- Characters that usually don't need to be escaped -->
<xsl:variable name="safe">
<xsl:text>!'()*-.0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz~</xsl:text>
</xsl:variable>
<xsl:variable name="hex">0123456789ABCDEF</xsl:variable>
<xsl:template name="datafield">
<xsl:param name="tag"/>
<xsl:param name="ind1">
<xsl:text> </xsl:text>
</xsl:param>
<xsl:param name="ind2">
<xsl:text> </xsl:text>
</xsl:param>
<xsl:param name="subfields"/>
<xsl:element name="marc:datafield">
<xsl:attribute name="tag">
<xsl:value-of select="$tag"/>
</xsl:attribute>
<xsl:attribute name="ind1">
<xsl:value-of select="$ind1"/>
</xsl:attribute>
<xsl:attribute name="ind2">
<xsl:value-of select="$ind2"/>
</xsl:attribute>
<xsl:copy-of select="$subfields"/>
</xsl:element>
</xsl:template>
<xsl:template name="subfieldSelect">
<xsl:param name="codes">abcdefghijklmnopqrstuvwxyz</xsl:param>
<xsl:param name="delimeter">
<xsl:text> </xsl:text>
</xsl:param>
<xsl:variable name="str">
<xsl:for-each select="marc:subfield">
<xsl:if test="contains($codes, @code)">
<xsl:value-of select="text()"/>
<xsl:value-of select="$delimeter"/>
</xsl:if>
</xsl:for-each>
</xsl:variable>
<xsl:value-of select="substring($str,1,string-length($str)-string-length($delimeter))"/>
</xsl:template>
<xsl:template name="buildSpaces">
<xsl:param name="spaces"/>
<xsl:param name="char">
<xsl:text> </xsl:text>
</xsl:param>
<xsl:if test="$spaces>0">
<xsl:value-of select="$char"/>
<xsl:call-template name="buildSpaces">
<xsl:with-param name="spaces" select="$spaces - 1"/>
<xsl:with-param name="char" select="$char"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<xsl:template name="chopPunctuation">
<xsl:param name="chopString"/>
<xsl:param name="punctuation">
<xsl:text>.:,;/ </xsl:text>
</xsl:param>
<xsl:variable name="length" select="string-length($chopString)"/>
<xsl:choose>
<xsl:when test="$length=0"/>
<xsl:when test="contains($punctuation, substring($chopString,$length,1))">
<xsl:call-template name="chopPunctuation">
<xsl:with-param name="chopString" select="substring($chopString,1,$length - 1)"/>
<xsl:with-param name="punctuation" select="$punctuation"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="not($chopString)"/>
<xsl:otherwise>
<xsl:value-of select="$chopString"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="chopPunctuationFront">
<xsl:param name="chopString"/>
<xsl:variable name="length" select="string-length($chopString)"/>
<xsl:choose>
<xsl:when test="$length=0"/>
<xsl:when test="contains('.:,;/[ ', substring($chopString,1,1))">
<xsl:call-template name="chopPunctuationFront">
<xsl:with-param name="chopString" select="substring($chopString,2,$length - 1)"
/>
</xsl:call-template>
</xsl:when>
<xsl:when test="not($chopString)"/>
<xsl:otherwise>
<xsl:value-of select="$chopString"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="chopPunctuationBack">
<xsl:param name="chopString"/>
<xsl:param name="punctuation">
<xsl:text>.:,;/] </xsl:text>
</xsl:param>
<xsl:variable name="length" select="string-length($chopString)"/>
<xsl:choose>
<xsl:when test="$length=0"/>
<xsl:when test="contains($punctuation, substring($chopString,$length,1))">
<xsl:call-template name="chopPunctuation">
<xsl:with-param name="chopString" select="substring($chopString,1,$length - 1)"/>
<xsl:with-param name="punctuation" select="$punctuation"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="not($chopString)"/>
<xsl:otherwise>
<xsl:value-of select="$chopString"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- nate added 12/14/2007 for lccn.loc.gov: url encode ampersand, etc. -->
<xsl:template name="url-encode">
<xsl:param name="str"/>
<xsl:if test="$str">
<xsl:variable name="first-char" select="substring($str,1,1)"/>
<xsl:choose>
<xsl:when test="contains($safe,$first-char)">
<xsl:value-of select="$first-char"/>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="codepoint">
<xsl:choose>
<xsl:when test="contains($ascii,$first-char)">
<xsl:value-of
select="string-length(substring-before($ascii,$first-char)) + 32"
/>
</xsl:when>
<xsl:when test="contains($latin1,$first-char)">
<xsl:value-of
select="string-length(substring-before($latin1,$first-char)) + 160"/>
<!-- was 160 -->
</xsl:when>
<xsl:otherwise>
<xsl:message terminate="no">Warning: string contains a character
that is out of range! Substituting "?".</xsl:message>
<xsl:text>63</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="hex-digit1"
select="substring($hex,floor($codepoint div 16) + 1,1)"/>
<xsl:variable name="hex-digit2" select="substring($hex,$codepoint mod 16 + 1,1)"/>
<!-- <xsl:value-of select="concat('%',$hex-digit2)"/> -->
<xsl:value-of select="concat('%',$hex-digit1,$hex-digit2)"/>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="string-length($str) &gt; 1">
<xsl:call-template name="url-encode">
<xsl:with-param name="str" select="substring($str,2)"/>
</xsl:call-template>
</xsl:if>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
<!-- Stylus Studio meta-information - (c)1998-2002 eXcelon Corp.
<metaInformation>
<scenarios/><MapperInfo srcSchemaPath="" srcSchemaRoot="" srcSchemaPathIsRelative="yes" srcSchemaInterpretAsXML="no" destSchemaPath="" destSchemaRoot="" destSchemaPathIsRelative="yes" destSchemaInterpretAsXML="no"/>
</metaInformation>
-->
UNPATCHED_MARC21SLIMUTIL
my $noppn_mods_res = "<mods version=\"3.6\"
xmlns=\"http://www.loc.gov/mods/v3\"
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
xsi:schemaLocation=\"http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-6.xsd\">
<identifier>string</identifier>
</mods>
";
# preparation
my $exportToArchiveDate = "2020-08-05_10-26-11";
my $ppn = "457035137";
my $noppn = "";
my $marc21;
my $mods;
my @addBagInfo = (
{'SLUBArchiv-sipVersion' => 'v2020.1'},
{'SLUBArchiv-externalWorkflow' => 'kitodo'},
......@@ -660,27 +161,15 @@ if(! -d $output_path) { mkdir $output_path or die "Error creating directory: tmp
#~ └── tmp
#~ └── bagit
my $xsl_path = path(__FILE__)->parent->parent->child('xsl')->absolute();
my $ua = LWP::UserAgent->new;
my $request = HTTP::Request->new('GET' => "https://sru.bsz-bw.de/swbf");
my $response = $ua->request($request);
my $marc21slimutils_file = $xsl_path->child('MARC21slimUtils.xsl');
my $useragent_obj = LWP::UserAgent->new;
$useragent_obj->agent("MyApp/0.1 ");
$useragent_obj->timeout(3600); #1h
# ensure no dir exists, then run test
if($xsl_path->is_dir){ $xsl_path->remove_tree; }
### tests
BEGIN { use_ok("SLUB::LZA::SIPBuilderBagIt"); }
# *************************************************************************** test old functions ******************************************************************************************************************
#
is(SLUB::LZA::SIPBuilderBagIt::check_xsl_directory(), $xsl_path->absolute, "check_xsl_directory(), return value if not exist");
ok($xsl_path->is_dir, "check_xsl_directory(), created if not exist");
is(SLUB::LZA::SIPBuilderBagIt::check_xsl_directory(), $xsl_path->absolute, "check_xsl_directory(), return value if exist");
ok($xsl_path->is_dir, "check_xsl_directory(), untouched if exist");
#
SKIP: {
skip "No response from server https://sru.bsz-bw.de/swb", 1 unless ! $response->is_error;
......@@ -695,32 +184,6 @@ throws_ok{ SLUB::LZA::SIPBuilderBagIt::get_marc21_from("https://sru.bsz-bw.de/sw
throws_ok{ SLUB::LZA::SIPBuilderBagIt::get_marc21_from("https://sru.bsz-bw.de/swb", $ppn, undef, "marcxmlvbos"); } qr/key not defined/, "get_marc21_from(\$url, \$ppn, \$key, \$schema), key undef";
throws_ok{ SLUB::LZA::SIPBuilderBagIt::get_marc21_from("https://sru.bsz-bw.de/swb", $ppn, "pica.swn", undef); } qr/schema not defined/, "get_marc21_from(\$url, \$ppn, \$key, \$schema), schema undef";
#
ok(SLUB::LZA::SIPBuilderBagIt::write_file($marc21slimutils_file, $unpatched_marc21slimutils), "write_file()");
throws_ok{ SLUB::LZA::SIPBuilderBagIt::write_file("", $unpatched_marc21slimutils); } qr/invalid parameters/, "write_file(), invalid parameters";
throws_ok{ SLUB::LZA::SIPBuilderBagIt::write_file($marc21slimutils_file, ""); } qr/invalid parameters/, "write_file(), invalid parameters";
throws_ok{ SLUB::LZA::SIPBuilderBagIt::write_file(undef, $unpatched_marc21slimutils); } qr/filename not defined/, "write_file(\$filename, \$value), filename undef";
throws_ok{ SLUB::LZA::SIPBuilderBagIt::write_file($marc21slimutils_file, undef); } qr/value not defined/, "write_file(\$filename, \$value), value undef";
#
is(SLUB::LZA::SIPBuilderBagIt::patch_mods($unpatched_mods_obj), $patched_mods, "patch_mods()");
throws_ok{ SLUB::LZA::SIPBuilderBagIt::patch_mods(""); } qr/invalid parameters/, "patch_mods(), invalid parameters";
throws_ok{ SLUB::LZA::SIPBuilderBagIt::patch_mods(undef); } qr/modsobject not defined/, "patch_mods(\$modsobj), modsobj undef";
#
is(SLUB::LZA::SIPBuilderBagIt::patch_marc_response($unpatched_marcblob_obj), $patched_marcblob, "patch_marc_response()");
throws_ok{ SLUB::LZA::SIPBuilderBagIt::patch_marc_response(""); } qr/invalid parameters/, "patch_marc_response(), invalid parameters";
throws_ok{ SLUB::LZA::SIPBuilderBagIt::patch_marc_response(undef); } qr/marcobject not defined/, "patch_marc_response(\$marcobj), marcobj undef";
#
is(SLUB::LZA::SIPBuilderBagIt::check_marc21_utility($xsl_path, $useragent_obj), $marc21slimutils_file , "check_marc21_utility()");
throws_ok{ SLUB::LZA::SIPBuilderBagIt::check_marc21_utility("", $useragent_obj); } qr/invalid parameters/, "check_marc21_utility(), invalid parameters";
throws_ok{ SLUB::LZA::SIPBuilderBagIt::check_marc21_utility($xsl_path, ""); } qr/invalid parameters/, "check_marc21_utility(), invalid parameters";
throws_ok{ SLUB::LZA::SIPBuilderBagIt::check_marc21_utility(undef, $useragent_obj); } qr/xsl directory not defined/, "check_marc21_utility(\$xsl_dir, \$useragent), xsl_dir undef";
throws_ok{ SLUB::LZA::SIPBuilderBagIt::check_marc21_utility($xsl_path, undef); } qr/user agent not defined/, "check_marc21_utility(\$xsl_dir, \$useragent), useragent undef";
# #
like(SLUB::LZA::SIPBuilderBagIt::check_marc21_mods_xsl($xsl_path, $useragent_obj), qr/xsl\/MARC21slim2MODS3-6\.patched\.xsl$/, "check_marc21_mods_xsl()");
throws_ok{ SLUB::LZA::SIPBuilderBagIt::check_marc21_mods_xsl("", $useragent_obj); } qr/invalid parameters/, "check_marc21_mods_xsl(), invalid parameters";
throws_ok{ SLUB::LZA::SIPBuilderBagIt::check_marc21_mods_xsl($xsl_path, ""); } qr/invalid parameters/, "check_marc21_mods_xsl(), invalid parameters";
throws_ok{ SLUB::LZA::SIPBuilderBagIt::check_marc21_mods_xsl(undef, $useragent_obj); } qr/xsl directory not defined/, "check_marc21_mods_xsl(\$xsl_dir, \$useragent), xsl_dir undef";
throws_ok{ SLUB::LZA::SIPBuilderBagIt::check_marc21_mods_xsl($xsl_path, undef); } qr/user agent not defined/, "check_marc21_mods_xsl(\$xsl_dir, \$useragent), useragent undef";
#
ok( $marc21 = SLUB::LZA::SIPBuilderBagIt::get_marc21_from_catalogue($ppn), "get_marc21_from_catalogue(), valid");
like( $marc21, qr/<datafield tag="/, "get_marc21_from_catalogue(), valid");
throws_ok{ SLUB::LZA::SIPBuilderBagIt::get_marc21_from_catalogue(""); } qr/ppn not defined/, "get_marc21_from_catalogue(), invalid";
......@@ -732,11 +195,6 @@ throws_ok{ SLUB::LZA::SIPBuilderBagIt::get_marc21_text_node(undef, { tag => "245
throws_ok{ SLUB::LZA::SIPBuilderBagIt::get_marc21_text_node($marc21, "" ); } qr/not a mapping hash/, "get_marc21_text_node(), invalid";
throws_ok{ SLUB::LZA::SIPBuilderBagIt::get_marc21_text_node($marc21, undef); } qr/not a mapping hash/, "get_marc21_text_node(), invalid";
#
ok( $mods = SLUB::LZA::SIPBuilderBagIt::get_mods_from_marc21($marc21), "get_mods_from_marc21(), valid");
like( $mods, qr/<mods.*xmlns="http:\/\/www\.loc\.gov\/mods\/v3\"/, "get_mods_from_marc21(), valid");
throws_ok{ SLUB::LZA::SIPBuilderBagIt::get_mods_from_marc21(""); } qr/marc21 empty/, "get_mods_from_marc21(), invalid";
throws_ok{ SLUB::LZA::SIPBuilderBagIt::get_mods_from_marc21(undef); } qr/marc21 empty/, "get_mods_from_marc21(), invalid";
#
my @baginfo_got = @addBagInfo;
my @baginfo_expected = @addBagInfo;
push @baginfo_expected, (
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment