Bug 36397 - t/db_dependent/Koha/Plugins/authority_hooks.t fails with Elasticsearch
Summary: t/db_dependent/Koha/Plugins/authority_hooks.t fails with Elasticsearch
Status: Pushed to main
Alias: None
Product: Koha
Classification: Unclassified
Component: Test Suite (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal (vote)
Assignee: Marcel de Rooy
QA Contact: Katrin Fischer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-03-22 09:44 UTC by Marcel de Rooy
Modified: 2024-03-22 11:28 UTC (History)
2 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
24.05.00


Attachments
Bug 36397: Quick fix for Koha/Plugins/authority_hooks.t (2.11 KB, patch)
2024-03-22 09:50 UTC, Marcel de Rooy
Details | Diff | Splinter Review
Bug 36397: Quick fix for Koha/Plugins/authority_hooks.t (2.12 KB, patch)
2024-03-22 10:16 UTC, David Nind
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Marcel de Rooy 2024-03-22 09:44:08 UTC
See also bug 35536 comment60

#   Failed test 'AddAuthority calls the hook with action=create, id passed'
    #   at /kohadevbox/koha/t/db_dependent/Koha/Plugins/authority_hooks.t line 57.
     # found warning: Cannot determine authority type for record: 1740 at /kohadevbox/koha/Koha/SearchEngine/Elasticsearch.pm line 573.
     # found warning: Plugin error (Test Plugin): Exception 'Koha::Exception' thrown 'after_authority_action called with action: create, id: 1740'
     # expected to find warning: (?^u:after_authority_action called with action: create, id: \d+)
 
    #   Failed test 'ModAuthority calls the hook with action=modify, id passed'
    #   at /kohadevbox/koha/t/db_dependent/Koha/Plugins/authority_hooks.t line 61.
     # found warning: Cannot determine authority type for record: 1740 at /kohadevbox/koha/Koha/SearchEngine/Elasticsearch.pm line 573.
     # found warning: Plugin error (Test Plugin): Exception 'Koha::Exception' thrown 'after_authority_action called with action: modify, id: 1740'
     # expected to find warning: (?^u:after_authority_action called with action: modify, id: 1740)
     # Looks like you failed 2 tests of 3.
Comment 1 Marcel de Rooy 2024-03-22 09:45:28 UTC
Failing test
    warning_like { ( $id ) = C4::AuthoritiesMarc::AddAuthority( MARC::Record->new, undef, 'PERSO_NAME' ); }
            qr/after_authority_action called with action: create, id: \d+/,
            'AddAuthority calls the hook with action=create, id passed';

It triggers another warning about no authtype when using Elastic:

Crashes on this part in marc_records_to_documents
            my $authtypecode = GuessAuthTypeCode( $record );
            if( $authtypecode ){
                if( $authtypecode !~ m/_SUBD/ ){ #Subdivision records will not be used for linking and so don't require match-heading to be built
                    my $field = $record->field( $auth_match_headings{ $authtypecode } );
                    my $heading = C4::Heading->new_from_field( $field, undef, 1 ); #new auth heading
                    push @{$record_document->{'match-heading'}}, $heading->search_form if $heading;
                }
            } else {
                warn "Cannot determine authority type for record: " . $record->field('001')->as_string;
Comment 2 Marcel de Rooy 2024-03-22 09:50:11 UTC
Created attachment 163668 [details] [review]
Bug 36397: Quick fix for Koha/Plugins/authority_hooks.t

Lazy approach for now: just ignore the other warnings that are
logical when passing blank records to SearchEngine. Elastic is
a bit more sensitive than Zebra here..

Test plan:
Run t/db_dependent/Koha/Plugins/authority_hooks.t

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 3 David Nind 2024-03-22 10:16:08 UTC
Created attachment 163672 [details] [review]
Bug 36397: Quick fix for Koha/Plugins/authority_hooks.t

Lazy approach for now: just ignore the other warnings that are
logical when passing blank records to SearchEngine. Elastic is
a bit more sensitive than Zebra here..

Test plan:
Run t/db_dependent/Koha/Plugins/authority_hooks.t

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: David Nind <david@davidnind.com>
Comment 4 Katrin Fischer 2024-03-22 11:28:45 UTC
Pushed for 24.05!

Well done everyone, thank you!