Bugzilla – Attachment 134999 Details for
Bug 30756
Get skip block out of Koha_Authority.t and add TestBuilder
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30756: Further adjustments to Koha_Authority.t
Bug-30756-Further-adjustments-to-KohaAuthorityt.patch (text/plain), 15.50 KB, created by
Marcel de Rooy
on 2022-05-14 12:31:43 UTC
(
hide
)
Description:
Bug 30756: Further adjustments to Koha_Authority.t
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2022-05-14 12:31:43 UTC
Size:
15.50 KB
patch
obsolete
>From 242493899b042d15c4655b89f2c1465f0ecb2a38 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Sat, 14 May 2022 12:07:17 +0000 >Subject: [PATCH] Bug 30756: Further adjustments to Koha_Authority.t >Content-Type: text/plain; charset=utf-8 > >Remove use of exported_records file in favor of TestBuilder. >Remove conditional tests with SKIP block. Create reservoir record. > >Test plan: >Run t/db_dependent/Koha_Authority.t > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > t/db_dependent/Koha_Authority.t | 107 ++++++++---------- > .../zebraexport/authority/exported_records | 1 - > 2 files changed, 47 insertions(+), 61 deletions(-) > delete mode 100644 t/db_dependent/data/marc21/zebraexport/authority/exported_records > >diff --git a/t/db_dependent/Koha_Authority.t b/t/db_dependent/Koha_Authority.t >index 159bb3bb20..4369df3195 100755 >--- a/t/db_dependent/Koha_Authority.t >+++ b/t/db_dependent/Koha_Authority.t >@@ -1,5 +1,6 @@ > #!/usr/bin/perl > >+# Copyright 2022 Koha Development Team, Marcel de Rooy > # Copyright 2012 C & P Bibliography Services > # > # This file is part of Koha. >@@ -19,15 +20,12 @@ > > use Modern::Perl; > use Test::More tests => 3; >+use Data::Dumper qw/Dumper/; > >-use File::Basename; >-use MARC::Batch; >-use MARC::File; >-use IO::File; >+use MARC::File::XML; >+ >+use t::lib::TestBuilder; > >-use C4::Context; >-use C4::Charset qw( MarcToUTF8Record ); >-use C4::AuthoritiesMarc qw( AddAuthority ); > use Koha::Database; > use Koha::Authorities; > >@@ -37,71 +35,60 @@ BEGIN { > > our $schema = Koha::Database->new->schema; > $schema->storage->txn_begin; >-our $dbh = C4::Context->dbh; >- >-subtest 'Part 1' => sub { >- # TODO Move this part to a t/lib packages >- my $sourcedir = dirname(__FILE__) . "/data"; >- my $input_marc_file = "$sourcedir/marc21/zebraexport/authority/exported_records"; >- >- my $fh = IO::File->new($input_marc_file); >- my $batch = MARC::Batch->new( 'USMARC', $fh ); >- while ( my $record = $batch->next ) { >- C4::Charset::MarcToUTF8Record($record, 'MARC21'); >- AddAuthority($record, '', ''); >- } >- >- my $record = MARC::Record->new; >- $record->add_fields( >- [ '001', '1234' ], >- [ '150', ' ', ' ', a => 'Cooking' ], >- [ '450', ' ', ' ', a => 'Cookery' ], >- ); >- my $authority = Koha::MetadataRecord::Authority->new($record); >- >+our $builder = t::lib::TestBuilder->new; >+ >+our $record1 = MARC::Record->new; >+$record1->add_fields( >+ [ '001', '1234' ], >+ [ '150', ' ', ' ', a => 'Cooking' ], >+ [ '450', ' ', ' ', a => 'Cookery' ], >+); >+our $record2 = MARC::Record->new; >+$record2->add_fields( >+ [ '001', '2345' ], >+ [ '150', ' ', ' ', a => 'Baking' ], >+ [ '450', ' ', ' ', a => 'Bakery' ], >+); >+ >+subtest 'Test new, authorized_heading, authid, get_from_authid' => sub { >+ plan tests => 7; >+ >+ my $auth1 = $builder->build_object({ class => 'Koha::Authorities', >+ value => { marcxml => $record1->as_xml }, >+ }); >+ my $auth2 = $builder->build_object({ class => 'Koha::Authorities', >+ value => { marcxml => $record2->as_xml }, >+ }); >+ >+ my $authority = Koha::MetadataRecord::Authority->new( $record1 ); > is(ref($authority), 'Koha::MetadataRecord::Authority', 'Created valid Koha::MetadataRecord::Authority object'); >- > is($authority->authorized_heading(), 'Cooking', 'Authorized heading was correct'); >+ is_deeply($authority->record, $record1, 'Saved record'); > >- is_deeply($authority->record, $record, 'Saved record'); >- >- my $authid = Koha::Authorities->search->next->authid; >- >- $authority = Koha::MetadataRecord::Authority->get_from_authid($authid); >- >+ $authority = Koha::MetadataRecord::Authority->get_from_authid( $auth2->id ); > is(ref($authority), 'Koha::MetadataRecord::Authority', 'Retrieved valid Koha::MetadataRecord::Authority object'); >- >- is($authority->authid, $authid, 'Object authid is correct'); >- >- is($authority->record->field('001')->data(), $authid, 'Retrieved correct record'); >+ is($authority->authid, $auth2->id, 'Object authid is correct'); >+ is($authority->record->field('001')->data(), '2345', 'Retrieved original 001'); # Note: not created via AddAuthority > > $authority = Koha::MetadataRecord::Authority->get_from_authid('alphabetsoup'); > is($authority, undef, 'No invalid record is retrieved'); > }; > >-subtest 'Part2' => sub { >- SKIP: { >- my $sth = $dbh->prepare("SELECT import_record_id FROM import_records WHERE record_type = 'auth' LIMIT 1;"); >- $sth->execute(); >- >- my $import_record_id; >- for my $row ($sth->fetchrow_hashref) { >- $import_record_id = $row->{'import_record_id'}; >- } >+subtest 'Test get_from_breeding' => sub { >+ plan tests => 4; > >- skip 'No authorities in reservoir', 3 unless $import_record_id; >- my $authority = Koha::MetadataRecord::Authority->get_from_breeding($import_record_id); >+ my $import = $builder->build({ source => 'ImportRecord', >+ value => { marcxml => $record1->as_xml, record_type => 'auth' }, >+ }); >+ my $import_record_id = $import->{import_record_id}; > >- is(ref($authority), 'Koha::MetadataRecord::Authority', 'Retrieved valid Koha::MetadataRecord::Authority object'); >- >- is($authority->authid, undef, 'Records in reservoir do not have an authid'); >- >- is(ref($authority->record), 'MARC::Record', 'MARC record attached to authority'); >+ my $authority = Koha::MetadataRecord::Authority->get_from_breeding($import_record_id); >+ is(ref($authority), 'Koha::MetadataRecord::Authority', 'Retrieved valid Koha::MetadataRecord::Authority object'); >+ is($authority->authid, undef, 'Records in reservoir do not have an authid'); >+ is(ref($authority->record), 'MARC::Record', 'MARC record attached to authority'); > >- $authority = Koha::MetadataRecord::Authority->get_from_breeding('alphabetsoup'); >- is($authority, undef, 'No invalid record is retrieved from reservoir'); >- } >- done_testing(); >+ $authority = Koha::MetadataRecord::Authority->get_from_breeding('alphabetsoup'); >+ is($authority, undef, 'No invalid record is retrieved from reservoir'); > }; > > $schema->storage->txn_rollback; >diff --git a/t/db_dependent/data/marc21/zebraexport/authority/exported_records b/t/db_dependent/data/marc21/zebraexport/authority/exported_records >deleted file mode 100644 >index 930c9451af..0000000000 >--- a/t/db_dependent/data/marc21/zebraexport/authority/exported_records >+++ /dev/null >@@ -1 +0,0 @@ >-08502cz a2201729n 45000010002000000030004000020050017000060080041000230100031000640350023000950400145001180460037002630460023003000530019003231000037003423700080003793720012004593740017004713740022004883740018005103750009005283770008005374000036005454000037005814000037006184000035006554000036006904000033007264000028007594000041007874000034008284000031008624000031008934000027009244000037009514000037009884000031010254000047010564000034011034000039011374000038011764000024012144000026012384000033012644000039012974000035013364000039013714000025014104000039014354000034014744000040015084000042015484000030015904000041016204000043016614000038017044000029017424000028017714000026017994000045018254000045018704000061019154000052019764000047020284000045020754000057021204000055021774000053022324000035022854000061023204000049023814000061024304000062024914000052025534000031026054000037026364000059026734000047027324000049027794000061028284000050028894000057029394000059029964000048030554000031031034000047031344000029031814000035032104000045032454000057032904000055033474000041034024000043034434000055034864000055035414000041035964000053036374000042036904000042037324000042037744000040038164000053038564000035039094000040039444000044039844000044040284000058040724000042041304000040041724000038042124000038042504000038042884000038043264000035043644000029043996670056044286670047044846700052045316700097045836700084046806700094047646700049048586700070049076700031049776700058050086700134050666700066052006700056052666700054053226700068053766700071054446700091055156700051056066700026056576700106056836700122057896700055059116700134059666700067061006700071061676700044062386700045062826700040063276700310063676780080066779420015067576DLC20131010200219.0831215n| azannaabn |b aaa an 78095332 zsh 85120820 a(OCoLC)oca00230409 aDLCbengerdacDLCdDLCdMHdOCoLCdNjPdIUdWUdDLCdOCoLCdWUdDLCdDLC-OKdUkdSG-SiILAdCU-HEdUkdDLCdInUdOCoLCdCStdOCoLCdCStdUPB f[..1564-04-26]g1616-04-232edtf f15640426g16160423 0aPR2750bPR31121 aShakespeare, William,d1564-1616 aStratford-upon-Avon, EnglandbStratford-upon-Avon, EnglandeLondon, England aTheatre aPoet2itoamc aDramatist2itoamc aActor2itoamc amale aeng1 aShakspeare, William,d1564-16161 aSÌekÊ»spiri, Uiliam,d1564-16161 aSaixpeÌr, Gouilliam,d1564-16161 aShakspere, William,d1564-16161 aShikisbiÌr, Wilyam,d1564-16161 aSzekspir, Wiliam,d1564-16161 aSÌekspyras,d1564-16161 aShekspir, Vilʹiï¸ a︡m,d1564-16161 aSÌekspir, Viljem,d1564-16161 aTsikinya-chaka,d1564-16161 aSha-shih-pi-ya,d1564-16161 aShashibiya,d1564-16161 aShekÌ£spir, VÌ£ilyam,d1564-16161 aShakÌ£spir, VÌ£ilyam,d1564-16161 aSyeiksuÌpÊ»io,d1564-16161 aShekspir, V.q(Vilʹiï¸ a︡m),d1564-16161 aSzekspir, William,d1564-16161 aShakespeare, Guglielmo,d1564-16161 aShake-speare, William,d1564-16160 aSha-oÌ,d1564-16161 aŞekspir,d1564-16161 aShekspir, Uiliam,d1564-16161 aShekspir, U.q(Uiliam),d1564-16161 aSÌekspir, Vilijam,d1564-16161 aSÌ£eÌkspiyar, Viliyam,d1564-16161 aShakspir,d1564-16161 aShekspyr, Vyliï¸ e︡m,d1564-16161 aŞekspir, Velyam,d1564-16161 aSÌ£eÌkspiyar, Villiyam,d1564-16161 aSheÌkÊ»spÊ»iyr, Vlilliam,d1564-16161 aSÌ£eÌkspiyar,d1564-16161 aSÌ£eÌkspiyar MahaÌkavi,d1564-16161 aSÌ£eÌkspiyar MahaÌkaviya,d1564-16161 aShekÌ£spier, VÌ£ilyam,d1564-16161 aSheÌkÊ»spir,d1564-16161 aShakespeare,d1564-16160 aSÌeksper,d1564-16161 aШекÑпиÑ, ÐилÑÑм,d1564-16161 aШекÑпиÑ, УилÑÑм,d1564-16161 aש××קספ×ר, ×××××××,âªâªâªâªd1564-16161 aש××קספ×ר, ××.,âªâªâªâªd1564-16161 aש×קספ×ר, ×××××××âªâªâªâª1 aש×קספ×ר, ××××××âªâªâªâª1 aש×קספ×ר, ××××××,âªâªâªâªd1564-16161 aש×ספ×ר, ××××××,âªâªâªâªd1564-16161 aש×ספ×ר, ×××××,âªâªâªâªd1564-16161 aש×ספ×ר, ×׳âªâªâªâª1 aשעפקספ×ר, ×××××××,âªâªâªâªd1564-16161 aשעקספ×ער, ×××××××âªâªâªâª1 aשעקספ×ער, ×××××××,âªâªâªâªd1564-16161 aשעקספ×ער, ××××××××âªâªâªâªd1564-16161 aשעקספ×ער, ××.,âªâªâªâªd1564-16161 aשעקספ×רâªâªâªâª1 aשעקספ×ר, ××âªâªâªâª1 aשעקספ×ר, ×××××××,âªâªâªâªd1564-16161 aשעקספ×ר, ×××××××âªâªâªâª1 aשעקספ×ר, ××××××××âªâªâªâª1 aשעקספ×ר, ××××××××,âªâªâªâªd1564-16161 aשעקספ×ר, ××.,âªâªâªâªd1564-16161 aשעקספ×ר, ×°×××××,âªâªâªâªd1564-16161 aשעקספ×ר, ×°××××××,âªâªâªâªd1564-16161 aשעקספ×ר, ×°.,âªâªâªâªd1564-16161 aשעקספערâªâªâªâª1 aשעקספער, ×××××××âªâªâªâª1 aשקספ×רâªâªâªâª1 aשקספ×ר, ××âªâªâªâª1 aשקספ×ר, ×××××××âªâªâªâª1 aשקספ×ר, ×××××××,âªâªâªâªd1564-16161 aשקספ×ר, ××××××,âªâªâªâªd1564-16161 aשקספ×ר, ×××××âªâªâªâª1 aשקספ×ר, ××××××âªâªâªâª1 aשקספ×ר, ××××××,âªâªâªâªd1564-16161 aשקספ×ר, ××××××,âªâªâªâªd1564-16161 aשקספ×ר, ×××××âªâªâªâª1 aשקספ×ר, ×××××,âªâªâªâªd1564-16161 aشاÙسبÙØ±Ø ÙÙÙÙâªâªâªâª1 aشاÙسپÙØ±Ø ÙÙÙÙâªâªâªâª1 aØ´ÙسبÙØ±Ø ÙÙÙاÙâªâªâªâª1 aØ´ÙسبÙØ±Ø ÙÙÙÙâªâªâªâª1 aØ´ÙسبÙØ±Ø ÙÙÙÙØâªâªâªâªd1564-16161 aØ´ÙسبÙØ±Ø Ù.âªâªâªâª1 aØ´ÙسپÙØ±Ø ÙÙÙÙâªâªâªâª1 aØ´ÙسپÙØ±Ø ÙÙÙÙاÙâªâªâªâª1 aØ´ÙÙسبÙØ±Ø ÙÙÙاÙâªâªâªâª1 aØ´ÙÙسبÙØ±Ø ÙÙÙاÙ.Øâªâªâªâªd1564-16161 aØ´ÙÙسبÙØ±Ø ÙÙÙÙâªâªâªâª1 aشکسبÙØ±Ø ÙÙÙÙâªâªâªâª1 aÙÙÙ٠شکسبÙرâªâªâªâª1 aæ²å£«åäºå¨å»å§,d1564-16161 aæ²å£«æ¯äºå¨å»å§,d1564-16161 aè士æ¯äºå¨å»å§,d1564-16161 aè士æ¯äºå¨å»,d1564-16161 aè士æ¯äº,d1564-1616 aMachine-derived non-Latin script reference project. aNon-Latin script references not evaluated. aPlessow, G. L. Um Shakespeares nordentum, 1937. aSha-shih-pi-ya yen chiu wen chi, 1982 (subj.)bt.p. (Sha-shih-pi-ya) cover p. 4 (Shashibiya) aHis The plays and poems of William Shakspeare, 1966:bt.p. (William Shakspeare) aHamletÌ£ vÌ£e-ShekÌ£spir, c1983:bp. 19 (VÌ£ilyam ShekÌ£spir; b. 4-26-1564; d. 4-25-1616) aSyeiksuÌpÊ»io, 1978:bt.p. (SyeiksuÌpÊ»io) aIskusstvo klassicheskogo monologa [SR] 19--:blabel (V. Shekspir) aUiliam SÌekÊ»spiri, 1996. aHelsztynÌski, S. Wizerunek Williama Szekspira, 1947. anuc86-2792: Doccioli, M. Fonti italiane dei drammi di Guglielmo Shakespeare [MI] 1914b(hdg.: on NIC rept.: Shakespeare, William) aHis Shake-speares sonnets, 1984:bt.p. (William Shake-speare) aHis Toroirasu to Kureshida, 1927:bp. 290 (Sha-oÌ) aNihon kokugo d.j.b(Sha-oÌ: Shakespeare William) aHis Kral Lir, 1912:bt.p. (Şekspir; W. Shakespeare [in rom.]) aUiliam Shekspir, 1982:bt.p. (Uiliam Shekspir) cover (U. Shekspir) aObradovicÌ, M. "Narodna demokratija" u Jugoslaviji, 1995:bp. [5] (Vilijam SÌekspir) aHaÌmletÌ£, 1962:bt.p (Viliyam SÌ£eÌkspiyar) aNaÌy Shakspir, 1972. aBL auth. file, 10 Nov. 2004b(refs.: Shekspyr, Vyliï¸ e︡m, 1564-1616; Şekspir, Velyam, 1564-1616) aSILAS database, Dec. 28, 2004b(hdg.: Shakespeare, William, 1564-1616; usages: Villiyam SÌ£eÌkspiyar; SÌ£eÌkspiyar) aRuÌmiyoo JuÌliy-e qoyar, 1988:bt.p. (SÌeksper) aLC database, Dec. 28, 2004b(hdg.: Shakespeare, William, 1564-1616; usages: SÌ£eÌkspiyar MahaÌkavi; SÌ£eÌkspiyar MahaÌkaviya) aYulius Tsezar, 1918:bt.p. (VÌ£ilyam ShekÌ£spier [part. voc.]) aHrÌ£omeÌos ew CiwleeÌdda, 1866:bp. 9 (Vlilliam SheÌkÊ»spÊ»iyr) aArkÊ»ay Lir, 2006:bt.p. (SheÌkÊ»spir) aHark, hark the lark, 1934b(Shakespeare) aHis My cellphone number is 99282477 aEncyclopedia Britannica, via WWW, Aug. 31, 2012b(William Shakespeare; William Shakspere; byname Bard of Avon or Swan of Avon; baptized Apr. 26, 1564 in Stratford-upon-Avon, Warwickshire, Eng.; d. Apr. 23, 1616 in Stratford-upon-Avon; English poet, dramatist, and actor; worked in London from around 1592)0 aWilliam Shakespeare (1564-1616) was an English poet, playwright, and actor. aPERSO_NAME00789cz a2200217n 45000010005000000030004000050050017000090080041000260100017000670400023000840530018001071000016001254000012001414000016001534000014001694000027001836700192002106700084004026700070004869420015005561709DLC20181024104214.0991028n| acannaabn |a aaa an 99282477 aDLCbengcDLCdDLC 0aPS3556.O391731 aFoley, Mick0 aMankind0 aCactus Jack0 aDude Love1 aFoley, Michael Francis aHis Have a nice day! 2000:bCIP t.p. (Mankind) galley (Mick Foley; professional wrestler who has taken on various names in his career: Dude Love, Cactus Jack, and, most recently, Mankind) aMick Foley tribute page (WWW), Oct. 28, 1999b(Cactus Jack, Dude Love, Mankind) aMick Foley, c2000:bp. 7 (Michael Francis Foley, b. July 7, 1965) aPERSO_NAME >\ No newline at end of file >-- >2.20.1
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 30756
:
134998
|
134999
|
135000
|
135004
|
135005
|
135006
|
135104
|
135105
|
135106
|
135702