Bugzilla – Attachment 24208 Details for
Bug 10486
Allow external Z39.50 targets to be searched from the OPAC
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 10486 QA followup: Fix license headers, add tests
Bug-10486-QA-followup-Fix-license-headers-add-test.patch (text/plain), 11.19 KB, created by
Chris Cormack
on 2014-01-12 00:47:14 UTC
(
hide
)
Description:
Bug 10486 QA followup: Fix license headers, add tests
Filename:
MIME Type:
Creator:
Chris Cormack
Created:
2014-01-12 00:47:14 UTC
Size:
11.19 KB
patch
obsolete
>From 5aa4ffe6643e4599d63547ab545bf2da6371ebd5 Mon Sep 17 00:00:00 2001 >From: Jesse Weaver <pianohacker@gmail.com> >Date: Wed, 8 Jan 2014 16:11:28 -0700 >Subject: [PATCH] Bug 10486 QA followup: Fix license headers, add tests > >XSLT.t is the only one modified, so to run the tests, just do: > > prove t/XSLT.t > >Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz> >--- > koha-tmpl/opac-tmpl/lib/pz2.js | 18 +++++++- > opac/opac-external-search.pl | 22 +++++----- > opac/svc/pazpar2_init | 27 ++++++------ > t/XSLT.t | 94 +++++++++++++++++++++++++++++++++++------- > 4 files changed, 120 insertions(+), 41 deletions(-) > >diff --git a/koha-tmpl/opac-tmpl/lib/pz2.js b/koha-tmpl/opac-tmpl/lib/pz2.js >index 9d693b2..4234c07 100644 >--- a/koha-tmpl/opac-tmpl/lib/pz2.js >+++ b/koha-tmpl/opac-tmpl/lib/pz2.js >@@ -1,6 +1,20 @@ > /* >- * $Id: 3a9980787bb5d0fe966140b243a4a5eb6768913e $ >-** pz2.js - pazpar2's javascript client library. >+ * pz2.js - pazpar2's javascript client library. >+ * Copyright (C) 2006-2013 Index Data. >+ * >+ * This program is free software; you can redistribute it and/or >+ * modify it under the terms of the GNU General Public License >+ * as published by the Free Software Foundation; either version 2 >+ * of the License, or (at your option) any later version. >+ * >+ * This program is distributed in the hope that it will be useful, >+ * but WITHOUT ANY WARRANTY; without even the implied warranty of >+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+ * GNU General Public License for more details. >+ * >+ * You should have received a copy of the GNU General Public License >+ * along with this program; if not, write to the Free Software >+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. > */ > > //since explorer is flawed >diff --git a/opac/opac-external-search.pl b/opac/opac-external-search.pl >index 70737e2..8bd3f4f 100755 >--- a/opac/opac-external-search.pl >+++ b/opac/opac-external-search.pl >@@ -1,21 +1,21 @@ > #!/usr/bin/perl > >-# Copyright 2009 BibLibre SARL >+# Copyright 2013 ByWater Solutions > # > # This file is part of Koha. > # >-# Koha is free software; you can redistribute it and/or modify it under the >-# terms of the GNU General Public License as published by the Free Software >-# Foundation; either version 2 of the License, or (at your option) any later >-# version. >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. > # >-# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >-# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. > # >-# You should have received a copy of the GNU General Public License along >-# with Koha; if not, write to the Free Software Foundation, Inc., >-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. > > use strict; > use warnings; >diff --git a/opac/svc/pazpar2_init b/opac/svc/pazpar2_init >index 5a0a472..3c9fc6d 100755 >--- a/opac/svc/pazpar2_init >+++ b/opac/svc/pazpar2_init >@@ -1,21 +1,21 @@ > #!/usr/bin/perl > >-# Copyright 2013 ByWater >+# Copyright 2013 ByWater Solutions > # > # This file is part of Koha. > # >-# Koha is free software; you can redistribute it and/or modify it under the >-# terms of the GNU General Public License as published by the Free Software >-# Foundation; either version 2 of the License, or (at your option) any later >-# version. >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. > # >-# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >-# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. > # >-# You should have received a copy of the GNU General Public License along >-# with Koha; if not, write to the Free Software Foundation, Inc., >-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. > > =head1 NAME > >@@ -23,12 +23,13 @@ svc/pazpar2_init: Initialize a Pazpar2 session > > =head1 SYNOPSIS > >-svc/pazpar2_init?targets=3,5,9 -> ../pazpar2/search.pz2?command=init&... >+svc/pazpar2_init -> ../pazpar2/search.pz2?command=init&... > > =head1 DESCRIPTION > > This services connects to pazpar2 and authenticates connections on behalf of >-client-side search code. >+client-side search code. The proxy is necessary to prevent exposing >+authentication information. > > =cut > >diff --git a/t/XSLT.t b/t/XSLT.t >index 64cd597..d9aaf24 100755 >--- a/t/XSLT.t >+++ b/t/XSLT.t >@@ -6,7 +6,11 @@ > use strict; > use warnings; > >-use Test::More tests => 8; >+use C4::Context; >+use C4::Templates; >+use Test::More tests => 13; >+use Test::MockModule; >+use File::Basename qw/dirname/; > use File::Temp; > use File::Path qw/make_path/; > >@@ -14,36 +18,96 @@ BEGIN { > use_ok('C4::XSLT'); > } > >-my $dir = File::Temp->newdir(); >+my $opacdir = File::Temp->newdir(); >+my $staffdir = File::Temp->newdir(); > my @themes = ('prog', 'test'); > my @langs = ('en', 'es-ES'); > >+sub make_test_file { >+ my ( $filename, $contents ) = @_; >+ >+ make_path(dirname($filename)); >+ open my $fh, '>', $filename or die "Could not create test file: $filename"; >+ print $fh $contents; >+ close $fh; >+} >+ > # create temporary files to be tested later > foreach my $theme (@themes) { > foreach my $lang (@langs) { >- make_path("$dir/$theme/$lang/xslt"); >- open my $fh, '>', "$dir/$theme/$lang/xslt/my_file.xslt"; >- print $fh "Theme $theme, language $lang"; >- close $fh; >+ foreach my $dir ($opacdir, $staffdir) { >+ make_test_file( "$dir/$theme/$lang/xslt/my_file.xslt", "Theme $theme, language $lang" ); >+ make_test_file( "$dir/$theme/$lang/xslt/MARC21slim2intranetDetail.xsl", "Theme $theme, language $lang, MARC21slim2intranetDetail" ); >+ make_test_file( "$dir/$theme/$lang/xslt/test_en.xsl", "Theme $theme, language $lang, test_en" ); >+ make_test_file( "$dir/$theme/$lang/xslt/UNIMARCslim2OPACDetail.xsl", "Theme $theme, language $lang, UNIMARCslim2OPACDetail" ); >+ make_test_file( "$dir/$theme/$lang/xslt/nondefault_test.xsl", "Theme $theme, language $lang, nondefault_test" ); >+ make_test_file( "$dir/$theme/$lang/xslt/MARC21slim2OPACResults.xsl", "Theme $theme, language $lang, MARC21slim2OPACResults" ); >+ } > } > } > >-sub find_and_slurp { >+sub find_and_slurp_default { > my ($dir, $theme, $lang) = @_; > > my $filename = C4::XSLT::_get_best_default_xslt_filename($dir, $theme, $lang, 'my_file.xslt'); >- open my $fh, '<', $filename; >+ open my $fh, '<', $filename or return "Could not open: $filename"; > my $str = <$fh>; > close $fh; > return $str; > } > >+sub find_and_slurp { >+ my ($marcflavour, $xslsyspref) = @_; >+ >+ my $filename = C4::XSLT::XSLTGetFilename( $marcflavour, $xslsyspref ); >+ open my $fh, '<', $filename or return "Could not open: $filename"; >+ my $str = <$fh>; >+ close $fh; >+ return $str; >+} >+ >+my $module_context = new Test::MockModule('C4::Context'); >+$module_context->mock( >+ 'config', >+ sub { >+ my ( $self, $var ) = @_; >+ my %predefs = ( >+ opachtdocs => $opacdir, >+ intrahtdocs => $staffdir, >+ ); >+ >+ return $predefs{$var} || $module_context->original('config')->(@_); >+ } >+); >+$module_context->mock( >+ 'preference', >+ sub { >+ my ( $self, $var ) = @_; >+ my %predefs = ( >+ template => 'prog', >+ marcflavour => 'MARC21', >+ opacthemes => 'test', >+ XSLTDetailsDisplay => 'default', >+ XSLTResultsDisplay => "$staffdir/prog/en/xslt/test_en.xsl", >+ OPACXSLTDetailsDisplay => "$opacdir/test/en/xslt/nondefault_test.xsl", >+ OPACXSLTResultsDisplay => '"default"', >+ ); >+ >+ return $predefs{$var} || $module_context->original('preference')->(@_); >+ } >+); >+ > # These tests verify that we're finding the right XSLT file when present, > # and falling back to the right XSLT file when an exact match is not present. >-is(find_and_slurp($dir, 'test', 'en' ), 'Theme test, language en', 'Found test/en'); >-is(find_and_slurp($dir, 'test', 'es-ES'), 'Theme test, language es-ES', 'Found test/es-ES'); >-is(find_and_slurp($dir, 'prog', 'en', ), 'Theme prog, language en', 'Found test/en'); >-is(find_and_slurp($dir, 'prog', 'es-ES'), 'Theme prog, language es-ES', 'Found test/es-ES'); >-is(find_and_slurp($dir, 'test', 'fr-FR'), 'Theme test, language en', 'Fell back to test/en for test/fr-FR'); >-is(find_and_slurp($dir, 'nope', 'es-ES'), 'Theme prog, language es-ES', 'Fell back to prog/es-ES for nope/es-ES'); >-is(find_and_slurp($dir, 'nope', 'fr-FR'), 'Theme prog, language en', 'Fell back to prog/en for nope/fr-FR'); >+is(find_and_slurp_default($opacdir, 'test', 'en' ), 'Theme test, language en', 'Found test/en'); >+is(find_and_slurp_default($opacdir, 'test', 'es-ES'), 'Theme test, language es-ES', 'Found test/es-ES'); >+is(find_and_slurp_default($opacdir, 'prog', 'en', ), 'Theme prog, language en', 'Found test/en'); >+is(find_and_slurp_default($opacdir, 'prog', 'es-ES'), 'Theme prog, language es-ES', 'Found test/es-ES'); >+is(find_and_slurp_default($opacdir, 'test', 'fr-FR'), 'Theme test, language en', 'Fell back to test/en for test/fr-FR'); >+is(find_and_slurp_default($opacdir, 'nope', 'es-ES'), 'Theme prog, language es-ES', 'Fell back to prog/es-ES for nope/es-ES'); >+is(find_and_slurp_default($opacdir, 'nope', 'fr-FR'), 'Theme prog, language en', 'Fell back to prog/en for nope/fr-FR'); >+is(find_and_slurp('MARC21', 'XSLTDetailsDisplay'), 'Theme prog, language en, MARC21slim2intranetDetail', 'Used default for staff/details'); >+is(find_and_slurp('MARC21', 'XSLTResultsDisplay'), 'Theme prog, language en, test_en', 'Used non-default with langcode for staff/results'); >+is(find_and_slurp('MARC21', 'OPACXSLTDetailsDisplay'), 'Theme test, language en, nondefault_test', 'not-prog: Used non-default for local marcflavour and opac/details'); >+is(find_and_slurp('UNIMARC', 'OPACXSLTDetailsDisplay'), 'Theme test, language en, UNIMARCslim2OPACDetail', 'not-prog: Used default for non-local marcflavour and opac/details'); >+is(find_and_slurp('MARC21', 'OPACXSLTResultsDisplay'), 'Theme test, language en, MARC21slim2OPACResults', 'not-prog: Used "default" for opac/results'); >-- >1.8.5.2
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 10486
:
19142
|
19143
|
19226
|
19227
|
19680
|
21687
|
21734
|
22084
|
22540
|
23109
|
23112
|
23113
|
24036
|
24206
|
24207
|
24208
|
25235
|
25236
|
25979
|
26002
|
26017
|
26129
|
26804
|
26988
|
27275
|
27276
|
27438
|
27439
|
27440
|
27559
|
27756
|
27781
|
27783
|
27785
|
27786
|
27787
|
27788
|
27789
|
27790