Bugzilla – Attachment 186742 Details for
Bug 40856
Improve Standard backend metadata retrieval
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40856: Add unit tests for Standard backend metadata method
Bug-40856-Add-unit-tests-for-Standard-backend-meta.patch (text/plain), 3.78 KB, created by
Tomás Cohen Arazi (tcohen)
on 2025-09-22 19:30:04 UTC
(
hide
)
Description:
Bug 40856: Add unit tests for Standard backend metadata method
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2025-09-22 19:30:04 UTC
Size:
3.78 KB
patch
obsolete
>From 2a24453c158822dd20496c232437ed5bd82a23cc Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Tom=C3=A1s=20Cohen=20Arazi?= <tomascohen@theke.io> >Date: Mon, 22 Sep 2025 16:24:27 -0300 >Subject: [PATCH] Bug 40856: Add unit tests for Standard backend metadata > method > >This patch adds comprehensive unit tests for the metadata() method in the >Standard ILL backend to establish baseline behavior before optimization. > >The tests cover: >- Metadata structure (returns hashref) >- Included attributes (title, author, isbn, year, custom fields) >- Excluded attributes (ignored fields like requested_partners, type, etc.) >- Display name transformation (attribute types become display names) > >Current behavior tested: >- metadata() filters out predefined ignore list attributes >- Uses linear search with grep for each attribute >- Transforms attribute types to display names (title -> Title) >- Custom fields get ucfirst transformation (custom_field -> Custom_field) >- Returns hashref with display names as keys > >These tests document the current inefficient implementation and will >ensure the upcoming optimization maintains compatibility. > >Test plan: >1. Apply patch >2. Run: > $ ktd --shell > k$ prove t/db_dependent/Koha/ILL/Backend/Standard.t >=> SUCCESS: Tests pass! Current metadata behavior documented >3. Tests establish baseline for upcoming optimization >4. Sign off :-D >--- > t/db_dependent/Koha/ILL/Backend/Standard.t | 48 +++++++++++++++++++++- > 1 file changed, 47 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/ILL/Backend/Standard.t b/t/db_dependent/Koha/ILL/Backend/Standard.t >index 652a3d21b9..318008c13c 100755 >--- a/t/db_dependent/Koha/ILL/Backend/Standard.t >+++ b/t/db_dependent/Koha/ILL/Backend/Standard.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 2; >+use Test::More tests => 3; > use Test::MockModule; > use Test::NoWarnings; > >@@ -113,3 +113,49 @@ subtest 'edititem() tests' => sub { > > $schema->storage->txn_rollback; > }; >+ >+subtest 'metadata() tests' => sub { >+ >+ plan tests => 8; >+ >+ $schema->storage->txn_begin; >+ >+ # Create a test ILL request >+ my $request = $builder->build_object( { class => 'Koha::ILL::Requests' } ); >+ >+ # Add various attributes including some that should be ignored >+ $request->add_or_update_attributes( >+ { >+ title => 'Test Title', >+ author => 'Test Author', >+ isbn => '1234567890', >+ year => '2023', >+ custom_field => 'custom_value', >+ >+ # These should be ignored by metadata() >+ requested_partners => 'partner@example.com', >+ type => 'book', >+ copyrightclearance_confirmed => '1', >+ unauthenticated_email => 'user@example.com' >+ } >+ ); >+ >+ my $backend = Koha::ILL::Backend::Standard->new; >+ my $metadata = $backend->metadata($request); >+ >+ # Check that metadata is a hashref >+ is( ref($metadata), 'HASH', 'metadata returns a hashref' ); >+ >+ # Check that included attributes are present (metadata uses display names) >+ is( $metadata->{Title}, 'Test Title', 'Title included in metadata' ); >+ is( $metadata->{Author}, 'Test Author', 'Author included in metadata' ); >+ is( $metadata->{ISBN}, '1234567890', 'ISBN included in metadata' ); >+ is( $metadata->{Year}, '2023', 'Year included in metadata' ); >+ is( $metadata->{Custom_field}, 'custom_value', 'Custom field included in metadata' ); >+ >+ # Check that ignored attributes are excluded >+ ok( !exists $metadata->{Requested_partners}, 'requested_partners excluded from metadata' ); >+ ok( !exists $metadata->{Copyrightclearance_confirmed}, 'copyrightclearance_confirmed excluded from metadata' ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.51.0
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 40856
:
186742
|
186743
|
186760
|
186761