Bugzilla – Attachment 33614 Details for
Bug 13264
Full stack encoding tests (UTF-8)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
test file plus two iso2709 records (unimarc and marc21)
0001-Bug-13264-a-basic-test-for-UTF-8-on-opac.patch (text/plain), 9.58 KB, created by
Zeno Tajoli
on 2014-11-17 13:13:19 UTC
(
hide
)
Description:
test file plus two iso2709 records (unimarc and marc21)
Filename:
MIME Type:
Creator:
Zeno Tajoli
Created:
2014-11-17 13:13:19 UTC
Size:
9.58 KB
patch
obsolete
>From a275052fe7ccbd176ec2e9da5cbdc60282d2c26b Mon Sep 17 00:00:00 2001 >From: Zeno Tajoli <z.tajoli@cineca.it> >Date: Mon, 17 Nov 2014 14:09:33 +0100 >Subject: [PATCH] Bug 13264: a basic test for UTF-8 on opac > >This test need to setup zebraserver and background indexing. >You need to set also KOHA_INTRANET_URL and KOHA_OPAC_URL >in the user enviroment. >--- > t/db_dependent/www/data/marc21utf8record.mrc | 1 + > t/db_dependent/www/data/unimarcutf8record.mrc | 1 + > t/db_dependent/www/opac_utf8.t | 217 +++++++++++++++++++++++++ > 3 files changed, 219 insertions(+) > create mode 100644 t/db_dependent/www/data/marc21utf8record.mrc > create mode 100644 t/db_dependent/www/data/unimarcutf8record.mrc > create mode 100644 t/db_dependent/www/opac_utf8.t > >diff --git a/t/db_dependent/www/data/marc21utf8record.mrc b/t/db_dependent/www/data/marc21utf8record.mrc >new file mode 100644 >index 0000000..57bbdd1 >--- /dev/null >+++ b/t/db_dependent/www/data/marc21utf8record.mrc >@@ -0,0 +1 @@ >+00893cam 2200205 a 4500001000800000005001700008008004100025020001500066035001200081040001300093049000700106050002200113245027800135260004500413300003400458650002500492650002000517650001400537952013600551100880920140204215200.0140204m2005 gr a 001 0 gre d a9603962481 a1008809 aAUHcAUH bb714aSB405.9bK57 200502aO deuteros κηÏοÏÏοÌÏ ÏÏο ÏÏιÌÏι ÏÎ±Ï :b1000 + 1 εÏÏÏηÌÏειÏ, 2000 + 2 αÏανÏηÌÏÎµÎ¹Ï /c[μεÏαÌÏÏαÏη ÎοÏζακιÌÏηÏ, ÎαÏιÌÎ»Î·Ï ; εÏιμεÌλεια - διοÌÏθÏÏη ÎαÏκαÏοÌλη ÎαÏιαÌννα. aÎθηÌνα :bÎÎÎÎÎÎÎÎ,c2005. a144 Ï. :bεικ. ;c29 εκ 4aÎηÏοÏÏÎ¹ÎºÎ·Ì 4aå¦åä¼. μμ 0aGardening 8main91380123ab7bb7g0l2m0oSB405.9.K57 2005p0070031504tc. 1xÎÏÎÎÏ ÎÎÎÎÎÎÎÎÎyd15zÎ10 - ÎζβθζμÏÏ Î·Ï >\ No newline at end of file >diff --git a/t/db_dependent/www/data/unimarcutf8record.mrc b/t/db_dependent/www/data/unimarcutf8record.mrc >new file mode 100644 >index 0000000..aeb825d >--- /dev/null >+++ b/t/db_dependent/www/data/unimarcutf8record.mrc >@@ -0,0 +1 @@ >+00862nam0a22002173i 4500001000200000005001700002090000600019100004100025101000800066200018700074210004300261215002400304600002000328601002000348702004700368702005200415710005500467801002300522942000700545995009200552220141116143328.0 a2 a20130409d2005 ||||0itay50 ba aita1 aÂO Âdeuteros pagosmios polemos kai to OlokautÅma tÅn ElliÄoÅ EvraiÅn, 1941 - 1944eEchirithio meletisfErena kai singrafi kimenÅn: Alexios MenexiadisgPanayota Andrianopoulou aAthinacEvraico Mouseio Ellathosd2005 a73 p.cill.d27 cm. 2å¦åä¼. μμ 2å¦åä¼. μμ 1aMenexiadisb, Alexios3IT\ICCU\LO1V\404551 1aAndrianopouloub, Panayota3IT\ICCU\LO1V\40455202aEvraico Mouseio Ellathos3IT\ICCU\LO1V\4045534070 3aITbICCUc20141104 cBK 0020304112233_00000000000000052014-11-1692btestctestf2014-0002k112233l2o0rBK >\ No newline at end of file >diff --git a/t/db_dependent/www/opac_utf8.t b/t/db_dependent/www/opac_utf8.t >new file mode 100644 >index 0000000..30b1855 >--- /dev/null >+++ b/t/db_dependent/www/opac_utf8.t >@@ -0,0 +1,217 @@ >+#!/usr/bin/perl >+ >+# Copyright 2012 C & P Bibliography Services >+# >+# This 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 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., 59 Temple Place, >+# Suite 330, Boston, MA 02111-1307 USA >+# >+ >+use Modern::Perl; >+use utf8; >+use Test::More; >+use Test::WWW::Mechanize; >+use Data::Dumper; >+use XML::Simple; >+use JSON; >+use File::Basename; >+use File::Spec; >+use POSIX; >+use Encode; >+ >+my $testdir = File::Spec->rel2abs( dirname(__FILE__) ); >+ >+my $koha_conf = $ENV{KOHA_CONF}; >+my $xml = XMLin($koha_conf); >+ >+use C4::Context; >+my $marcflavour = C4::Context->preference('marcflavour') || 'MARC21'; >+ >+# For the purpose of this test, we can reasonably take MARC21 and NORMARC to be the same >+my $file = >+ $marcflavour eq 'UNIMARC' >+ ? "$testdir/data/unimarcutf8record.mrc" >+ : "$testdir/data/marc21utf8record.mrc"; >+ >+my $user = $ENV{KOHA_USER} || $xml->{config}->{user}; >+my $password = $ENV{KOHA_PASS} || $xml->{config}->{pass}; >+my $intranet = $ENV{KOHA_INTRANET_URL}; >+my $opac = $ENV{KOHA_OPAC_URL}; >+ >+my $zebra_on = ProgProcesses('zebrasrv'); >+my $indexer_on = ProgProcesses('koha-index'); >+ >+if ($zebra_on < 2) { >+ plan skip_all => "Tests skip. You must start Zebra Server to do those tests\n"; >+} >+ >+if ($indexer_on < 2) { >+ plan skip_all => "Tests skip. You must start Zebra Background indexer to do those tests\n"; >+} >+ >+if (not defined $intranet) { >+ plan skip_all => "Tests skip. You must set env. variable KOHA_INTRANET_URL to do tests\n"; >+} >+if (not defined $opac) { >+ plan skip_all => "Tests skip. You must set env. variable KOHA_INTRANET_URL to do tests\n"; >+} >+ >+$intranet =~ s#/$##; >+$opac =~ s#/$##; >+ >+my $agent = Test::WWW::Mechanize->new( autocheck => 1 ); >+my $jsonresponse; >+ >+# -------------------------------------------------- LOAD RECORD >+ >+$agent->get_ok( "$intranet/cgi-bin/koha/mainpage.pl", 'connect to intranet' ); >+$agent->form_name('loginform'); >+$agent->field( 'password', $password ); >+$agent->field( 'userid', $user ); >+$agent->field( 'branch', '' ); >+$agent->click_ok( '', 'login to staff client' ); >+ >+$agent->get_ok( "$intranet/cgi-bin/koha/mainpage.pl", 'load main page' ); >+ >+$agent->follow_link_ok( { url_regex => qr/tools-home/i }, 'open tools module' ); >+$agent->follow_link_ok( { text => 'Stage MARC records for import' }, >+ 'go to stage MARC' ); >+ >+$agent->post( >+ "$intranet/cgi-bin/koha/tools/upload-file.pl", >+ [ 'fileToUpload' => [$file], ], >+ 'Content_Type' => 'form-data', >+); >+ok( $agent->success, 'uploaded file' ); >+ >+$jsonresponse = decode_json $agent->content(); >+is( $jsonresponse->{'status'}, 'done', 'upload succeeded' ); >+my $fileid = $jsonresponse->{'fileid'}; >+ >+$agent->get_ok( "$intranet/cgi-bin/koha/tools/stage-marc-import.pl", >+ 'reopen stage MARC page' ); >+$agent->submit_form_ok( >+ { >+ form_number => 5, >+ fields => { >+ 'uploadedfileid' => $fileid, >+ 'nomatch_action' => 'create_new', >+ 'overlay_action' => 'replace', >+ 'item_action' => 'always_add', >+ 'matcher' => '', >+ 'comments' => '', >+ 'encoding' => 'utf8', >+ 'parse_items' => '1', >+ 'runinbackground' => '1', >+ } >+ }, >+ 'stage MARC' >+); >+ >+$jsonresponse = decode_json $agent->content(); >+my $jobID = $jsonresponse->{'jobID'}; >+ok( $jobID, 'have job ID' ); >+ >+my $completed = 0; >+ >+# if we haven't completed the batch in two minutes, it's not happening >+for my $counter ( 1 .. 24 ) { >+ $agent->get( >+ "$intranet/cgi-bin/koha/tools/background-job-progress.pl?jobID=$jobID", >+ "get job progress" >+ ); >+ $jsonresponse = decode_json $agent->content(); >+ if ( $jsonresponse->{'job_status'} eq 'completed' ) { >+ $completed = 1; >+ last; >+ } >+ warn( >+ ( >+ $jsonresponse->{'job_size'} >+ ? floor( >+ 100 * $jsonresponse->{'progress'} / $jsonresponse->{'job_size'} >+ ) >+ : '100' >+ ) >+ . "% completed" >+ ); >+ sleep 5; >+} >+is( $jsonresponse->{'job_status'}, 'completed', 'job was completed' ); >+ >+$agent->get_ok( >+ "$intranet/cgi-bin/koha/tools/stage-marc-import.pl", >+ 'reopen stage MARC page at end of upload' >+); >+$agent->submit_form_ok( >+ { >+ form_number => 5, >+ fields => { >+ 'uploadedfileid' => $fileid, >+ 'nomatch_action' => 'create_new', >+ 'overlay_action' => 'replace', >+ 'item_action' => 'always_add', >+ 'matcher' => '1', >+ 'comments' => '', >+ 'encoding' => 'utf8', >+ 'parse_items' => '1', >+ 'runinbackground' => '1', >+ 'completedJobID' => $jobID, >+ } >+ }, >+ 'stage MARC' >+); >+ >+$agent->follow_link_ok( { text => 'Manage staged records' }, 'view batch' ); >+ >+ >+$agent->form_number(5); >+$agent->field( 'framework', '' ); >+$agent->click_ok( 'mainformsubmit', "imported records into catalog" ); >+my $webpage = $agent->{content}; >+ >+$webpage =~ /(.*<title>.*?)(\d{1,})(.*<\/title>)/sx; >+my $id_batch = $2; >+ >+#Wait the indexer >+sleep 35; >+ >+# -------------------------------------------------- TEST ON OPAC >+ >+ >+$agent->get_ok( "$opac" , "got opac"); >+$agent->form_name('searchform'); >+$agent->field( 'q', 'deuteros' ); >+$agent->field( 'idx', '' ); >+$agent->click( ); >+ >+# ok( $agent->success, 'uploaded file' ); >+ >+my $text = $agent->text() ; >+ >+#warn "1." . length(Encode::encode_utf8($text)) ; >+#warn "2." . length($text) ; >+ >+ok ( ( length(Encode::encode_utf8($text)) != length($text) ) , 'has UTF-8 characters. Good.') ; >+ >+ >+#-------------------------------------------------- REVERT >+ >+$agent->get_ok( "$intranet/cgi-bin/koha/tools/manage-marc-import.pl", 'view batch' ); >+$agent->form_name('clean_batch_'.$id_batch); >+$agent->click(); >+ >+done_testing(); >+ >+sub ProgProcesses { >+ return scalar grep /$_[0]/, (split /\n/, `ps -aef`); >+} >-- >1.7.10.4 >
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 13264
:
33614
|
33703
|
33704
|
33705
|
33743
|
33744
|
33756
|
33757
|
33758
|
33759
|
33760
|
33777
|
33778
|
33779
|
33780
|
33781
|
33782
|
33783
|
33784
|
33785
|
33786
|
33811
|
33812
|
33813
|
33814
|
33815
|
33816
|
33817
|
34110
|
34111
|
34112
|
34113
|
34114
|
34115
|
34116
|
34117
|
34694
|
34766
|
34767
|
34768
|
34769
|
34770
|
34771
|
34772
|
34773
|
34774
|
34775
|
34776
|
34798
|
34799
|
34800
|
34801
|
34802
|
34803
|
34804
|
34805
|
34806
|
34807
|
34808
|
34809
|
34810
|
34811
|
34814
|
35068
|
35069
|
35070
|
35071
|
35072
|
35073
|
35074
|
35075
|
35076
|
35077
|
35078
|
35079
|
35080
|
35081
|
35082
|
35110
|
35111
|
35112
|
35113
|
35114
|
35115
|
35116
|
35117
|
35118
|
35119
|
35120
|
35121
|
35122
|
35123
|
35124